Skip to content

Commit af03d7c

Browse files
authored
Merge pull request #24 from alpenlabs/state-machine-scaffolding
State machine scaffolding
2 parents da0ff3c + b65ba8a commit af03d7c

60 files changed

Lines changed: 2445 additions & 145 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 143 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ members = [
33
"crates/adaptor-sigs",
44
"crates/cac/crypto",
55
"crates/cac/proto-types",
6+
"crates/cac/protocol",
67
"crates/cac/types",
8+
"crates/common",
79
"crates/compute-exec",
810
"crates/compute-fw",
911
"crates/job/types",
12+
"crates/network/api",
1013
"crates/rpc/api",
1114
"crates/rpc/provider",
1215
"crates/rpc/server",
1316
"crates/rpc/types",
17+
"crates/state-machine/api",
18+
"crates/state-machine/executor",
19+
"crates/storage/api",
1420
"crates/table-types",
1521
"crates/vs3",
1622
]
@@ -42,24 +48,36 @@ clippy.too_long_first_doc_paragraph = "warn"
4248

4349
[workspace.dependencies]
4450
mosaic-cac-proto-types = { path = "crates/cac/proto-types" }
51+
mosaic-cac-protocol = { path = "crates/cac/protocol" }
52+
mosaic-cac-types = { path = "crates/cac/types" }
53+
mosaic-common = { path = "crates/common" }
4554
mosaic-compute-fw = { path = "crates/compute-fw" }
4655
mosaic-job-types = { path = "crates/job/types" }
4756
mosaic-rpc-api = { path = "crates/rpc/api" }
4857
mosaic-rpc-provider = { path = "crates/rpc/provider" }
4958
mosaic-rpc-types = { path = "crates/rpc/types" }
59+
mosaic-state-machine-api = { path = "crates/state-machine/api" }
60+
mosaic-state-machine-executor = { path = "crates/state-machine/executor" }
61+
mosaic-storage-api = { path = "crates/storage/api" }
5062
mosaic-table-types = { path = "crates/table-types" }
63+
mosaic-vs3 = { path = "crates/vs3" }
64+
5165
anyhow = "1.0"
5266
ark-ec = "0.5.0"
5367
ark-ff = "0.5.0"
5468
ark-secp256k1 = "0.5.0"
69+
async-trait = "0.1"
5570
bytes = "1.10"
71+
futures = "0.3.31"
5672
jsonrpsee = { version = "0.26.0", features = ["macros"] }
57-
jsonrpsee-types = "*" # constrained by jsonrpsee dep
73+
jsonrpsee-types = "*" # constrained by jsonrpsee dep
5874
rand = "0.8"
5975
rand_core = "0.6"
60-
serde = "1.0"
76+
serde = { version = "1.0", features = ["derive"] }
6177
strata-codec = { git = "https://github.com/alpenlabs/strata-common.git" }
6278
thiserror = "2.0"
79+
tokio = { version = "1.48.0", features = ["rt", "sync", "macros", "time"] }
80+
tokio-util = "0.7"
6381
tracing = "0.1"
6482

6583
[profile.release]

crates/cac/proto-types/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ categories.workspace = true
1111
keywords.workspace = true
1212

1313
[dependencies]
14+
mosaic-common.workspace = true
15+
1416
serde.workspace = true
1517

1618
[lints]

crates/cac/proto-types/src/game.rs

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
use mosaic_common::{PeerId, constants::N_SETUP_INPUT_WIRES};
12
use serde::{Deserialize, Serialize};
23

4+
use crate::TablesetInstanceId;
5+
36
/// Info about a CaC game.
47
#[derive(Clone, Debug, Deserialize, Serialize)]
5-
pub struct GameInfo {
8+
pub struct TablesetSetupInfo {
69
circuit_name: String,
710
role: CacRole,
8-
config: CacConfig,
9-
state: GameState,
11+
cac_params: CacParams,
12+
setup_inputs: SetupWireInputs,
13+
instance: TablesetInstanceId,
14+
peer: PeerId,
1015
}
1116

1217
/// The role the client should play in the garbling game.
@@ -20,32 +25,37 @@ pub enum CacRole {
2025
Evaluator,
2126
}
2227

23-
/// Configuration for the CaC game.
24-
#[derive(Clone, Debug, Deserialize, Serialize)]
25-
pub struct CacConfig {
26-
/// The number of tables we'll generate to start off.
27-
tables: u32,
28-
29-
/// The number of tables to open as part of the setup process.
30-
open: u32,
28+
/// Cac params that can be used to setup.
29+
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
30+
pub enum CacParams {
31+
/// default
32+
N181K174,
33+
/// for testing (only available in debug builds)
34+
#[cfg(debug_assertions)]
35+
N5K3,
3136
}
3237

33-
/// Describes the high-level state of a game.
34-
#[derive(Copy, Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
35-
#[serde(rename_all = "lowercase")]
36-
pub enum GameState {
37-
/// In the setup process.
38-
Setup,
39-
40-
/// Setup finished, ready to eval.
41-
Idle,
42-
43-
/// Evaluating.
44-
Evaling,
45-
46-
/// Evaluated.
47-
Evaled,
48-
49-
/// Dishonesty detected, aborted.
50-
Abort,
38+
impl CacParams {
39+
/// Total number of tables.
40+
pub fn tables(&self) -> u64 {
41+
match self {
42+
CacParams::N181K174 => 181,
43+
#[cfg(debug_assertions)]
44+
CacParams::N5K3 => 5,
45+
}
46+
}
47+
48+
/// Number of openings during Cac.
49+
pub fn selected_openings(&self) -> u64 {
50+
match self {
51+
CacParams::N181K174 => 174,
52+
#[cfg(debug_assertions)]
53+
CacParams::N5K3 => 3,
54+
}
55+
}
5156
}
57+
58+
/// Input wire values provided during setup.
59+
/// This corresponds to operator bridge pubkey.
60+
#[derive(Clone, Debug, Deserialize, Serialize)]
61+
pub struct SetupWireInputs([u8; N_SETUP_INPUT_WIRES]);

0 commit comments

Comments
 (0)