Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: RUES HTTP server | RUES Domain Layer Implementation #3302

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ ark-serialize = { version = "=0.4.2", default-features = false }
async-channel = "=1.9.0"
async-graphql = "=5.0.10"
async-trait = "=0.1.83"
axum = { version = "0.7.9", features = ["ws", "http2", "macros"] }
axum-macros = "0.4.1"
base64 = "=0.22.1"
blake2b_simd = { version = "=1.0.2", default-features = false }
blake3 = { version = "=1.5.4", default-features = false }
block-modes = "=0.8.1"
bs58 = "=0.4.0"
bytecheck = { version = "=0.6.12", default-features = false }
bytes = "1.9.0"
cargo_toml = "=0.15.3"
chrono = "=0.4.38"
clap = "=4.4.18"
Expand All @@ -83,6 +86,7 @@ criterion = "=0.5.1"
crossterm = "=0.25.0"
dirs = "=4.0.0"
dlmalloc = "=0.2.6"
either = "1.13.0"
fake = "=2.9.2"
ff = { version = "=0.13.0", default-features = false }
flate2 = "=1.0.33"
Expand All @@ -103,18 +107,21 @@ lru = "=0.12.4"
memory-stats = "=1.2.0"
metrics = "=0.22.3"
metrics-exporter-prometheus = "=0.14.0"
mockall = "0.13.1"
num-bigint = { version = "=0.4.6", default-features = false }
once_cell = "=1.19.0"
once_cell = "=1.20.2"
open = "=2.1.3"
parking_lot = "=0.12.3"
pin-project = "=1.1.5"
proptest = "1.6.0"
rand = { version = "=0.8.5", default-features = false }
rand_chacha = { version = "=0.3.1", default-features = false }
reqwest = "=0.12.7"
ringbuffer = "=0.15.0"
rkyv = { version = "=0.7.39", default-features = false }
rocksdb = { version = "=0.22.0", default-features = false }
rustc_tools_util = "=0.3.0"
rustls = "0.23.20"
rustls-pemfile = "=2.1.3"
semver = "=1.0.23"
serde = "=1.0.210"
Expand All @@ -128,14 +135,18 @@ sqlx = "=0.8.2"
tar = "=0.4.42"
tempdir = "=0.3.7"
tempfile = "=3.12.0"
test-case = "3.3.1"
thiserror = "=1.0.64"
time-util = "=0.3.4"
tiny-bip39 = "=0.8.2"
tokio = "=1.40.0"
tokio-rustls = "=0.26.0"
tokio-stream = "=0.1.16"
tokio-tungstenite = "*"
tokio-util = "=0.7.12"
toml = "=0.7.8"
tower = "0.5.2"
tower-http = { version = "0.6.2", features = ["trace", "cors"] }
tracing = "=0.1.40"
tracing-subscriber = "=0.3.18"
tungstenite = "=0.21.0"
Expand Down
46 changes: 44 additions & 2 deletions rusk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ name = "rusk"
path = "src/bin/main.rs"

[dependencies]
tokio = { workspace = true, features = ["rt-multi-thread", "fs", "macros"] }
tokio = { workspace = true, features = [
"rt-multi-thread",
"fs",
"macros",
"net",
] }
futures-util = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = [
"fmt",
"env-filter",
"json",
] }
chrono = { workspace = true, features = ["serde"] }
thiserror = { workspace = true }
clap = { workspace = true, features = ["env", "string", "derive"] }
semver = { workspace = true }
anyhow = { workspace = true }
Expand Down Expand Up @@ -78,15 +85,34 @@ reqwest = { workspace = true }
tempfile = { workspace = true, optional = true }
rusk-recovery = { workspace = true, optional = true }

## testwallet dependencies
## testwallet and http-server dependencies
futures = { workspace = true, optional = true }

## http-server dependencies
axum = { workspace = true, features = [
"ws",
"http2",
"macros",
], optional = true }
axum-macros = { workspace = true, optional = true }
bytes = { workspace = true, optional = true }
either = { workspace = true, optional = true }
mockall = { workspace = true, optional = true }
metrics = { workspace = true, optional = true }
once_cell = { workspace = true, optional = true }
proptest = { workspace = true, optional = true }
rustls = { workspace = true, optional = true }
tokio-tungstenite = { workspace = true, optional = true }
tower = { workspace = true, optional = true }
tower-http = { workspace = true, features = ["trace", "cors"], optional = true }

[dev-dependencies]
test-wallet = { version = "0.1.0", path = "../test-wallet" }
rusk-recovery = { workspace = true, features = ["state"] }
ff = { workspace = true }
rusk-prover = { workspace = true, features = ["no_random", "debug"] }
criterion = { workspace = true }
test-case = { workspace = true }

[build-dependencies]
rustc_tools_util = { workspace = true }
Expand All @@ -99,6 +125,7 @@ default = [
"prover",
"chain",
"http-wasm",
"http-server",
]
ephemeral = ["dep:rusk-recovery", "dep:tempfile", "recovery-state", "chain"]
recovery-state = ["rusk-recovery/state", "dep:tempfile"]
Expand All @@ -109,6 +136,21 @@ chain = ["dep:node", "dep:dusk-consensus", "dep:node-data"]
archive = ["chain", "node/archive"]
network-trace = ["node/network-trace"]
http-wasm = []
http-server = [
"dep:axum",
"dep:axum-macros",
"dep:bytes",
"dep:either",
"dep:futures",
"dep:metrics",
"dep:mockall",
"dep:proptest",
"dep:rustls",
"dep:tokio-tungstenite",
"dep:tower",
"dep:tower-http",
"dep:once_cell",
]

[[bench]]
name = "block_ingestion"
Expand Down
7 changes: 7 additions & 0 deletions rusk/src/lib/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

#![allow(unused)]
pub mod domain;
// mod infrastructure;
// mod handlers;
// mod router;
// mod state;

// pub mod application;
#[cfg(feature = "chain")]
mod chain;
mod event;
Expand All @@ -15,6 +21,7 @@ mod prover;
mod rusk;
mod stream;

// Re-export key types
pub(crate) use event::{
BinaryWrapper, DataType, ExecutionError, MessageResponse as EventResponse,
RequestData, Target,
Expand Down
64 changes: 64 additions & 0 deletions rusk/src/lib/http/domain/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) DUSK NETWORK. All rights reserved.

/// RUES binary format constants
pub mod binary {
/// RUES magic number ('0rsk')
pub const MAGIC_NUMBER: u32 = 0x0072_736b;

/// File types
pub mod file_type {
/// Rusk Smart Contract
pub const SMART_CONTRACT: u16 = 0x01;
/// Rusk Wallet
pub const WALLET: u16 = 0x02;
}

/// Field sizes in bytes
pub mod size {
/// Magic number field size
pub const MAGIC: usize = 4;
/// File type field size
pub const FILE_TYPE: usize = 2;
/// Reserved field size
pub const RESERVED: usize = 2;
/// Version field size
pub const VERSION: usize = 4;
/// Full header size
pub const HEADER: usize = MAGIC + FILE_TYPE + RESERVED + VERSION;
}

/// Field offsets in bytes
pub mod offset {
/// File type field offset
pub const FILE_TYPE: usize = super::size::MAGIC;
/// Reserved field offset
pub const RESERVED: usize = FILE_TYPE + super::size::FILE_TYPE;
/// Version field offset
pub const VERSION: usize = RESERVED + super::size::RESERVED;
}
}

/// RUES message format constants
pub mod message {
/// Maximum allowed size for message headers (1MB)
pub const MAX_HEADER_SIZE: u32 = 1024 * 1024;
}

/// RUES payload size limits
pub mod payload {
/// Maximum size for JSON payloads (10MB)
pub const MAX_JSON_SIZE: usize = 10 * 1024 * 1024;

/// Maximum size for binary payloads (50MB)
pub const MAX_BINARY_SIZE: usize = 50 * 1024 * 1024;

/// Maximum size for GraphQL queries (1MB)
pub const MAX_GRAPHQL_SIZE: usize = 1024 * 1024;

/// Maximum size for text payloads (1MB)
pub const MAX_TEXT_SIZE: usize = 1024 * 1024;
}
Loading
Loading