Skip to content

Commit

Permalink
Use zalloc for processor/message-queue/coordinator
Browse files Browse the repository at this point in the history
An additional layer which protects us against edge cases with Zeroizing
(objects which don't support it or don't miss it).
  • Loading branch information
kayabaNerve committed Jan 1, 2024
1 parent 7d2c47f commit 8bd2a0f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ frost-schnorrkel = { path = "../crypto/schnorrkel" }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive"] }

zalloc = { path = "../common/zalloc" }
serai-db = { path = "../common/db" }
serai-env = { path = "../common/env" }

Expand Down
4 changes: 4 additions & 0 deletions coordinator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ use cosign_evaluator::CosignEvaluator;
#[cfg(test)]
pub mod tests;

#[global_allocator]
static ALLOCATOR: zalloc::ZeroizingAlloc<std::alloc::System> =
zalloc::ZeroizingAlloc(std::alloc::System);

#[derive(Clone)]
pub struct ActiveTributary<D: Db, P: P2p> {
pub spec: TributarySpec,
Expand Down
1 change: 1 addition & 0 deletions message-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ env_logger = { version = "0.10", default-features = false, features = ["humantim
# Uses a single threaded runtime since this shouldn't ever be CPU-bound
tokio = { version = "1", default-features = false, features = ["rt", "time", "io-util", "net", "macros"] }

zalloc = { path = "../common/zalloc" }
serai-db = { path = "../common/db", optional = true }

serai-env = { path = "../common/env" }
Expand Down
10 changes: 7 additions & 3 deletions message-queue/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
mod messages;
mod queue;

pub(crate) use std::{
sync::{Arc, RwLock},
collections::HashMap,
Expand Down Expand Up @@ -38,6 +35,13 @@ mod clippy {
}
pub(crate) use self::clippy::*;

mod messages;
mod queue;

#[global_allocator]
static ALLOCATOR: zalloc::ZeroizingAlloc<std::alloc::System> =
zalloc::ZeroizingAlloc(std::alloc::System);

// queue RPC method
/*
Queues a message to be delivered from a processor to a coordinator, or vice versa.
Expand Down
1 change: 1 addition & 0 deletions processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ log = { version = "0.4", default-features = false, features = ["std"] }
env_logger = { version = "0.10", default-features = false, features = ["humantime"], optional = true }
tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "sync", "time", "macros"] }

zalloc = { path = "../common/zalloc" }
serai-db = { path = "../common/db", optional = true }
serai-env = { path = "../common/env", optional = true }
# TODO: Replace with direct usage of primitives
Expand Down
4 changes: 4 additions & 0 deletions processor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ use multisigs::{MultisigEvent, MultisigManager};
#[cfg(test)]
mod tests;

#[global_allocator]
static ALLOCATOR: zalloc::ZeroizingAlloc<std::alloc::System> =
zalloc::ZeroizingAlloc(std::alloc::System);

// Items which are mutably borrowed by Tributary.
// Any exceptions to this have to be carefully monitored in order to ensure consistency isn't
// violated.
Expand Down

0 comments on commit 8bd2a0f

Please sign in to comment.