Sphinx packet processing CPU cycles measurement (#3247)
* POC measurement * parentce76790761author durch <durch@users.noreply.github.com> 1680116778 +0200 committer durch <durch@users.noreply.github.com> 1680683399 +0200 Instrument packet processing * Cleanup and format * Feature gate tracing * Add .gitkeep to wallet dist * Squashed commit of the following: commit0b1b6947e8Author: Jon Häggblad <jon.haggblad@gmail.com> Date: Wed Apr 5 11:28:28 2023 +0200 Replace mobile flag with target_os = android (#3278) * Remove old lock file * Start replacing mobile with android * Regex replace all mobile with android * Remove the mobile feature flag * keep the cfg mobile in tauri commitc79b2cfb78Author: Jon Häggblad <jon.haggblad@gmail.com> Date: Wed Apr 5 11:27:38 2023 +0200 Service provider directory contract (#3220) * first commit of service provider directory contract proof of concept * *added config set on instantiation, *removed greetQuery test function * commit before mapping change * *changed mapping of service to use client address instead of cosmos addr * commit before mapping change * added acl to delete() * added test for acl in delete() * changed whitelist<vec> to standrd_whitelist bool in Service struct * removed old comments and commented out code * rustfmt * wup * wup * Older version of cw-multi-test that works with 1.0.0 * wip * Remove .gitignore * Basic tests for announce and query now works * Restore tests for delete as well * Consolidate tests * Tidy * fmt * Start reworking test helpers * Tidy tests * More test work * More test improvements * More work on tests * Tweaks * Further tests * rustfmt * Add some comments * Initial work on requiring deposit * wip * Work on updating tests for handling funds * Start updating integration tests * Integration tests updated * merge test mods in state * Address review comments * Enable wasm-opt * Unify Result type * consistent amount in error type * WIP: paging output * IndexedMap working * extract to config file * WIP: middle of extracting out types * Extract types * wip * Types now extracted out: * Paged response type too * rustfmt * Start working on switching to cw Admin * Complete switch to Admin * Remove owner from announce msg * remove unused imports * Assert owner * Extract out types to common crate * Fix test compilation * Add query by owner and nym address * Move msg to common crate * rustfmt * tests for service id * service storage tests * state services tests * function rename * tidy * Fix clippy warning * User ServiceId instead and not u32 * Delete by nym address * Emit explicit events * Swap ToString for Display * Move all storage keys to constants.rs * clippy * Test for deleting by name * Tidy integration tests * Remove to_string * Some comments to tests * Integration test for paging * serde snake_csae for NymAddress and ServiceType * Add migrate entry point * Add query contract version * A few more asserts for balance * Make MigrateMsg a struct --------- Co-authored-by: mx <maxhampshire@pm.me> commitdd699bce9aMerge:5ce017ef3e6957e7a9Author: Tommy Verrall <60836166+tommyv1987@users.noreply.github.com> Date: Wed Apr 5 10:18:16 2023 +0100 Merge pull request #3235 from nymtech/feature/performance-active-set-selection Feature/performance active set selection commit5ce017ef3dAuthor: benedetta davico <46782255+benedettadavico@users.noreply.github.com> Date: Wed Apr 5 10:57:45 2023 +0200 adding vesting tests (#3279) commit59c1ce2639Merge:4fb63d889276edfd56Author: Tommy Verrall <60836166+tommyv1987@users.noreply.github.com> Date: Wed Apr 5 09:50:53 2023 +0100 Merge pull request #3261 from nymtech/feature/refresh-allow-list Feature/refresh allow list commit4fb63d8892Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Wed Apr 5 09:22:43 2023 +0100 Feature/vesting delegation amount query (#3229) * moved queries and transactions out of contract.rs * added queries for vesting delegation details * nyxd_client support commit276edfd562Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 15:56:21 2023 +0100 clippy commit605f8fcde3Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 15:06:12 2023 +0100 updated and cleaned up tests commitf0e4d1a7cfAuthor: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 14:01:36 2023 +0100 configurable stored lists locations commit055ec4bdd5Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 12:57:02 2023 +0100 updating stored allow list on file changes commit5761f9ac7fAuthor: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 12:15:45 2023 +0100 file watcher commit32620fd55fAuthor: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Thu Mar 30 17:47:12 2023 +0100 updating standard list in a timer commitabb5cdbe06Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Thu Mar 30 16:43:58 2023 +0100 extracted domain and ipnet information to separate struct commite6957e7a99Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Tue Mar 28 11:25:43 2023 +0100 use combination of stake and performance for rewarded set selection commitde2406a2c7Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Tue Mar 28 10:54:14 2023 +0100 Moved MixnodeWithPerformance to helpers * Squashed commit of the following: commit0b1b6947e8Author: Jon Häggblad <jon.haggblad@gmail.com> Date: Wed Apr 5 11:28:28 2023 +0200 Replace mobile flag with target_os = android (#3278) * Remove old lock file * Start replacing mobile with android * Regex replace all mobile with android * Remove the mobile feature flag * keep the cfg mobile in tauri commitc79b2cfb78Author: Jon Häggblad <jon.haggblad@gmail.com> Date: Wed Apr 5 11:27:38 2023 +0200 Service provider directory contract (#3220) * first commit of service provider directory contract proof of concept * *added config set on instantiation, *removed greetQuery test function * commit before mapping change * *changed mapping of service to use client address instead of cosmos addr * commit before mapping change * added acl to delete() * added test for acl in delete() * changed whitelist<vec> to standrd_whitelist bool in Service struct * removed old comments and commented out code * rustfmt * wup * wup * Older version of cw-multi-test that works with 1.0.0 * wip * Remove .gitignore * Basic tests for announce and query now works * Restore tests for delete as well * Consolidate tests * Tidy * fmt * Start reworking test helpers * Tidy tests * More test work * More test improvements * More work on tests * Tweaks * Further tests * rustfmt * Add some comments * Initial work on requiring deposit * wip * Work on updating tests for handling funds * Start updating integration tests * Integration tests updated * merge test mods in state * Address review comments * Enable wasm-opt * Unify Result type * consistent amount in error type * WIP: paging output * IndexedMap working * extract to config file * WIP: middle of extracting out types * Extract types * wip * Types now extracted out: * Paged response type too * rustfmt * Start working on switching to cw Admin * Complete switch to Admin * Remove owner from announce msg * remove unused imports * Assert owner * Extract out types to common crate * Fix test compilation * Add query by owner and nym address * Move msg to common crate * rustfmt * tests for service id * service storage tests * state services tests * function rename * tidy * Fix clippy warning * User ServiceId instead and not u32 * Delete by nym address * Emit explicit events * Swap ToString for Display * Move all storage keys to constants.rs * clippy * Test for deleting by name * Tidy integration tests * Remove to_string * Some comments to tests * Integration test for paging * serde snake_csae for NymAddress and ServiceType * Add migrate entry point * Add query contract version * A few more asserts for balance * Make MigrateMsg a struct --------- Co-authored-by: mx <maxhampshire@pm.me> commitdd699bce9aMerge:5ce017ef3e6957e7a9Author: Tommy Verrall <60836166+tommyv1987@users.noreply.github.com> Date: Wed Apr 5 10:18:16 2023 +0100 Merge pull request #3235 from nymtech/feature/performance-active-set-selection Feature/performance active set selection commit5ce017ef3dAuthor: benedetta davico <46782255+benedettadavico@users.noreply.github.com> Date: Wed Apr 5 10:57:45 2023 +0200 adding vesting tests (#3279) commit59c1ce2639Merge:4fb63d889276edfd56Author: Tommy Verrall <60836166+tommyv1987@users.noreply.github.com> Date: Wed Apr 5 09:50:53 2023 +0100 Merge pull request #3261 from nymtech/feature/refresh-allow-list Feature/refresh allow list commit4fb63d8892Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Wed Apr 5 09:22:43 2023 +0100 Feature/vesting delegation amount query (#3229) * moved queries and transactions out of contract.rs * added queries for vesting delegation details * nyxd_client support commit276edfd562Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 15:56:21 2023 +0100 clippy commit605f8fcde3Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 15:06:12 2023 +0100 updated and cleaned up tests commitf0e4d1a7cfAuthor: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 14:01:36 2023 +0100 configurable stored lists locations commit055ec4bdd5Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 12:57:02 2023 +0100 updating stored allow list on file changes commit5761f9ac7fAuthor: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Fri Mar 31 12:15:45 2023 +0100 file watcher commit32620fd55fAuthor: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Thu Mar 30 17:47:12 2023 +0100 updating standard list in a timer commitabb5cdbe06Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Thu Mar 30 16:43:58 2023 +0100 extracted domain and ipnet information to separate struct commite6957e7a99Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Tue Mar 28 11:25:43 2023 +0100 use combination of stake and performance for rewarded set selection commitde2406a2c7Author: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com> Date: Tue Mar 28 10:54:14 2023 +0100 Moved MixnodeWithPerformance to helpers
This commit is contained in:
@@ -7,7 +7,7 @@ use crate::node::listener::connection_handler::packet_processing::{
|
||||
use crate::node::packet_delayforwarder::PacketDelayForwardSender;
|
||||
use crate::node::TaskClient;
|
||||
use futures::StreamExt;
|
||||
use log::{error, info};
|
||||
use mixnode_common::measure;
|
||||
use nym_sphinx::forwarding::packet::MixPacket;
|
||||
use nym_sphinx::framing::codec::SphinxCodec;
|
||||
use nym_sphinx::framing::packet::FramedSphinxPacket;
|
||||
@@ -16,6 +16,8 @@ use std::net::SocketAddr;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::time::Instant;
|
||||
use tokio_util::codec::Framed;
|
||||
#[cfg(feature = "cpucycles")]
|
||||
use tracing::{error, info, instrument};
|
||||
|
||||
pub(crate) mod packet_processing;
|
||||
|
||||
@@ -48,6 +50,10 @@ impl ConnectionHandler {
|
||||
.expect("the delay-forwarder has died!");
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "cpucycles",
|
||||
instrument(skip(self, framed_sphinx_packet), fields(cpucycles))
|
||||
)]
|
||||
fn handle_received_packet(&self, framed_sphinx_packet: FramedSphinxPacket) {
|
||||
//
|
||||
// TODO: here be replay attack detection - it will require similar key cache to the one in
|
||||
@@ -57,17 +63,19 @@ impl ConnectionHandler {
|
||||
|
||||
// all processing such, key caching, etc. was done.
|
||||
// however, if it was a forward hop, we still need to delay it
|
||||
match self.packet_processor.process_received(framed_sphinx_packet) {
|
||||
Err(err) => debug!("We failed to process received sphinx packet - {err}"),
|
||||
Ok(res) => match res {
|
||||
MixProcessingResult::ForwardHop(forward_packet, delay) => {
|
||||
self.delay_and_forward_packet(forward_packet, delay)
|
||||
}
|
||||
MixProcessingResult::FinalHop(..) => {
|
||||
warn!("Somehow processed a loop cover message that we haven't implemented yet!")
|
||||
}
|
||||
},
|
||||
}
|
||||
measure!({
|
||||
match self.packet_processor.process_received(framed_sphinx_packet) {
|
||||
Err(err) => debug!("We failed to process received sphinx packet - {err}"),
|
||||
Ok(res) => match res {
|
||||
MixProcessingResult::ForwardHop(forward_packet, delay) => {
|
||||
self.delay_and_forward_packet(forward_packet, delay)
|
||||
}
|
||||
MixProcessingResult::FinalHop(..) => {
|
||||
warn!("Somehow processed a loop cover message that we haven't implemented yet!")
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn handle_connection(
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::node::listener::connection_handler::ConnectionHandler;
|
||||
use log::error;
|
||||
use std::net::SocketAddr;
|
||||
use std::process;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::task::JoinHandle;
|
||||
#[cfg(feature = "cpucycles")]
|
||||
use tracing::error;
|
||||
|
||||
use super::TaskClient;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ use crate::node::listener::Listener;
|
||||
use crate::node::node_description::NodeDescription;
|
||||
use crate::node::node_statistics::SharedNodeStats;
|
||||
use crate::node::packet_delayforwarder::{DelayForwarder, PacketDelayForwardSender};
|
||||
use log::{error, info, warn};
|
||||
use mixnode_common::verloc::{self, AtomicVerlocResult, VerlocMeasurer};
|
||||
use nym_bin_common::output_format::OutputFormat;
|
||||
use nym_bin_common::version_checker::parse_version;
|
||||
@@ -28,6 +27,8 @@ use rand::thread_rng;
|
||||
use std::net::SocketAddr;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
#[cfg(feature = "cpucycles")]
|
||||
use tracing::{error, info, warn};
|
||||
|
||||
mod http;
|
||||
mod listener;
|
||||
|
||||
Reference in New Issue
Block a user