Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
42 changes: 21 additions & 21 deletions Cargo.lock

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

30 changes: 21 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resolver = "1"

[workspace.package]
edition = "2024"
version = "0.1.2-pre.9"
version = "0.1.2"
homepage = "https://spacejam.app"
repository = "https://github.com/spacejamapp/jade"
license = "GPL-3.0"
Expand Down Expand Up @@ -78,7 +78,11 @@ ark-ed-on-bls12-381-bandersnatch = { version = "0.5", default-features = false }
ark-ff = { version = "0.5", default-features = false }
ark-std = { version = "0.5", default-features = false }
ark-serialize = { version = "0.5", default-features = false }
ark-vrf = { version = "=0.2.1", features = ["bandersnatch", "ring", "parallel"] }
ark-vrf = { version = "=0.2.1", features = [
"bandersnatch",
"ring",
"parallel",
] }
async-trait = "0.1.89"
bindgen = "0.72"
blake2 = "0.10.6"
Expand Down Expand Up @@ -116,10 +120,22 @@ quinn = "0.11.9"
quote = "1.0.40"
rand = "0.8.5"
rayon = "1.11.0"
rcgen = { version = "0.13.2", default-features = false, features = ["crypto", "pem", "ring"] }
rcgen = { version = "0.13.2", default-features = false, features = [
"crypto",
"pem",
"ring",
] }
reed-solomon = { package = "reed-solomon-simd", version = "3.0.1" }
rustls = { version = "0.23.31", default-features = false, features = ["std", "logging", "tls12", "ring"] }
rustls-webpki = { version = "0.102.8", default-features = false, features = ["std", "ring"] }
rustls = { version = "0.23.31", default-features = false, features = [
"std",
"logging",
"tls12",
"ring",
] }
rustls-webpki = { version = "0.102.8", default-features = false, features = [
"std",
"ring",
] }
serde = { version = "1.0.219", features = ["derive"], default-features = false }
serde_json = { version = "1.0.143", default-features = false }
syn = "2.0.106"
Expand Down Expand Up @@ -152,9 +168,5 @@ uint = "0.10.0"
w3f-bls = "0.1.9"
x509-parser = "0.17.0"

[patch.crates-io]
# w3f-ring-proof = { git = "https://github.com/sunhuachuang/ring-proof" }
# ark-vrf = { git = "https://github.com/sunhuachuang/ark-vrf" }

[workspace.metadata.conta]
packages = ["codec", "spacejson-derive", "spacejson", "spec", "service"]
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,20 @@ dpush:
fpush: dpush
docker push $(DOCKER_IMAGE):int
docker push $(DOCKER_IMAGE):$(VERSION)-int

# Sample-profile `spacejam fuzz tx` on a trace directory via samply.
# Needs sudo (kernel.perf_event_paranoid=3 blocks unprivileged perf_event_open).
# Override:
# TRACE_DIR=res/foo/trace OUT=/tmp/foo.json.gz SPACEVM=true make profile-trace
TRACE_DIR ?= res/l2a/trace
OUT ?= /tmp/spacejam-trace.json.gz

.PHONY: profile-trace
profile-trace:
CARGO_PROFILE_RELEASE_DEBUG=line-tables-only \
cargo build --release -p spacejam --features trace
sudo SPACEVM=$(SPACEVM) $$(command -v samply) record --save-only -o $(OUT) \
./target/release/spacejam fuzz tx $(TRACE_DIR)
@echo ""
@echo "profile saved: $(OUT)"
@echo "view: samply load $(OUT)"
3 changes: 1 addition & 2 deletions crates/codec/erasure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ tiny = []
full = []

[dev-dependencies]
hex.workspace = true
serde_json.workspace = true
codec.workspace = true
specjam.workspace = true
10 changes: 1 addition & 9 deletions crates/codec/erasure/tests/consistency.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anyhow::Result;
use spacejam_erasure as erasure;
use specjam::Registry;
use std::path::PathBuf;
Expand All @@ -21,14 +20,7 @@ async fn run_codec(test: &str) -> anyhow::Result<()> {
specjam::Scale::Tiny
};
let test = registry.erasure(scale)?.test(test)?;
let mut data = hex::decode(test.input.trim_start_matches("0x"))?;
let shards = serde_json::from_str::<Vec<String>>(&test.output)?
.into_iter()
.map(|shard| {
hex::decode(shard.trim_start_matches("0x"))
.map_err(|e| anyhow::anyhow!("Failed to decode shard: {e}"))
})
.collect::<Result<Vec<_>>>()?;
let (mut data, shards) = codec::decode::<(Vec<u8>, Vec<Vec<u8>>)>(test.input.expect_bin()?)?;

let n = erasure::Config::default().original;
let recovery_pairs = || -> Vec<(usize, Vec<u8>)> {
Expand Down
3 changes: 2 additions & 1 deletion crates/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ w3f-bls = { workspace = true, optional = true }
tracing.workspace = true

[features]
default = []
default = ["tiny"]
tiny = []
full = []
blake2 = ["dep:blake2b_simd"]
blake3 = ["dep:blake3"]
Expand Down
13 changes: 9 additions & 4 deletions crates/crypto/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ pub use ed25519_zebra::{batch, Signature, SigningKey, VerificationKey, Verificat
use rand::rngs::OsRng;
use rayon::{iter::ParallelIterator, slice::ParallelSlice};

/// Number of signatures per parallel chunk for batch verification.
const BATCH_PAR_CHUNK: usize = 32;
/// Below this batch size, verify the whole slice as one ed25519 batch with
/// no rayon involvement.
const SEQUENTIAL_BATCH_THRESHOLD: usize = 32;

/// Chunk size when the batch is large enough to parallelize. Each chunk is
/// itself one ed25519 batch verification.
const PAR_CHUNK_SIZE: usize = 32;

/// Ed25519 key pair.
#[derive(Clone)]
Expand Down Expand Up @@ -71,11 +76,11 @@ pub fn batch_verify(items: &[(&[u8], [u8; 64], [u8; 32])]) -> anyhow::Result<()>
if items.is_empty() {
return Ok(());
}
if items.len() <= BATCH_PAR_CHUNK {
if items.len() <= SEQUENTIAL_BATCH_THRESHOLD {
return verify_batch(items);
}

items.par_chunks(BATCH_PAR_CHUNK).try_for_each(verify_batch)
items.par_chunks(PAR_CHUNK_SIZE).try_for_each(verify_batch)
}

fn verify_batch(items: &[(&[u8], [u8; 64], [u8; 32])]) -> anyhow::Result<()> {
Expand Down
6 changes: 6 additions & 0 deletions crates/crypto/src/ring.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
//! Bandersnatch ring related primitives
#![cfg(feature = "vrf")]

#[cfg(not(any(feature = "tiny", feature = "full")))]
compile_error!(
"spacejam-crypto/ring: enable one of `tiny` or `full` — \
otherwise the size-6 SRS is silently baked in (caused docker pre-11 BadTicketProof)"
);

use crate::vrf;
use ark_ec::AffineRepr;
use ark_serialize::CanonicalDeserialize;
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ tokio.workspace = true
tracing.workspace = true

[features]
default = ["timing"]
timing = []
tiny = ["score/tiny", "crypto/tiny"]
full = ["score/full", "crypto/full"]
1 change: 0 additions & 1 deletion crates/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod grandpa;
mod hook;
mod pool;
pub mod storage;
pub mod timing;
pub mod tx;
mod validator;

Expand Down
18 changes: 0 additions & 18 deletions crates/runtime/src/timing/disabled.rs

This file was deleted.

Loading
Loading