Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1edffd4
WIP add replication deps
cowlicks Feb 21, 2026
6557170
Add error from hc proto for replication
cowlicks Feb 21, 2026
159e380
Add peers to core
cowlicks Feb 22, 2026
90646e0
We're in 2024 now
cowlicks Feb 23, 2026
d0ecc05
WIP revisit after refactoring await all the `&mut self`
cowlicks Feb 23, 2026
9c9fea0
WIP update RandomAccess.len
cowlicks Feb 24, 2026
f008b01
rm async_std
cowlicks Feb 24, 2026
b1fc656
Add get_random_access
cowlicks Feb 24, 2026
997bc4e
RMME
cowlicks Feb 24, 2026
f59da0f
lints
cowlicks Feb 24, 2026
e1d1600
rm async-std
cowlicks Feb 24, 2026
805ef1b
fix the needless_pas_by_ref_mut
cowlicks Feb 24, 2026
a79047d
unnest
cowlicks Feb 24, 2026
ddfeeba
ignore for now
cowlicks Feb 24, 2026
14fdd8b
Add From<RamError> for HypercoreError
cowlicks Feb 25, 2026
be5fbdd
Add storage test
cowlicks Feb 25, 2026
fa282a3
Make flush_infos take Vec not slice
cowlicks Feb 25, 2026
659d6a2
Make Storage returnc owned futures
cowlicks Feb 25, 2026
3976700
Split core into two parts
cowlicks Feb 26, 2026
fb0a180
impl create_valueless_proof on Inner2
cowlicks Feb 27, 2026
f5253a3
add Inner2.verify_proof
cowlicks Mar 2, 2026
0757cc3
Add Inner2.byte_range
cowlicks Mar 2, 2026
9423cc5
Start using owned futures
cowlicks Mar 3, 2026
d16687f
add lint for unused async
cowlicks Mar 3, 2026
a0c3e4c
Fix mutex issues
cowlicks Mar 3, 2026
cf81436
implement Hypercore.get as owned future
cowlicks Mar 5, 2026
21df1cd
rewrite create_proof to return an owned future
cowlicks Mar 5, 2026
42f57e8
rewrite verify_and_apply_proof to return owned futures
cowlicks Mar 5, 2026
a596656
WIP add replication
cowlicks Mar 8, 2026
b709811
add tests, fix bug
cowlicks Mar 11, 2026
425a7c9
clippy --fix && cargo fmt
cowlicks Mar 11, 2026
657118d
fix lints that wouldn't auto-fix
cowlicks Mar 11, 2026
4d9315f
Remove futures replaced by owned futures
cowlicks Mar 11, 2026
081d098
Create master replicator
cowlicks Mar 14, 2026
4c15b8d
polling hypercore.get should drive replication
cowlicks Mar 16, 2026
9f5a613
use 'x.x.x-alpha' releases of random-access-* crates
cowlicks Mar 17, 2026
beb7780
remove async_std
cowlicks Mar 18, 2026
922b684
bump hypercore_handshake
cowlicks May 18, 2026
667393f
More replication tests
cowlicks May 18, 2026
78fcba7
Add more attach_replicator tests
cowlicks May 19, 2026
1fb9c99
no more "tokio" feature
cowlicks Jun 1, 2026
f27f432
rm unused features from CI
cowlicks Jun 1, 2026
a137346
Remove shared core.
cowlicks Jun 1, 2026
41e1913
More thorough CI.
cowlicks Jun 1, 2026
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
105 changes: 42 additions & 63 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,18 @@ jobs:
components: rustfmt
- name: Run tests
run: |
cargo check --all-targets --no-default-features --features tokio
cargo check --all-targets --no-default-features --features tokio,sparse
cargo check --all-targets --no-default-features --features tokio,sparse,cache
cargo check --all-targets --no-default-features --features async-std
cargo check --all-targets --no-default-features --features async-std,sparse
cargo check --all-targets --no-default-features --features async-std,sparse,cache
cargo test --no-default-features --features js_interop_tests,tokio
cargo test --no-default-features --features js_interop_tests,tokio,shared-core
cargo test --no-default-features --features js_interop_tests,tokio,sparse
cargo test --no-default-features --features js_interop_tests,tokio,sparse,cache
cargo test --no-default-features --features js_interop_tests,async-std
cargo test --no-default-features --features js_interop_tests,async-std,shared-core
cargo test --no-default-features --features js_interop_tests,async-std,sparse
cargo test --no-default-features --features js_interop_tests,async-std,sparse,cache
cargo test --benches --no-default-features --features tokio
cargo test --benches --no-default-features --features async-std

cargo check --all-targets
cargo check --all-targets --all-features
cargo check --all-targets --no-default-features
cargo check --all-targets --no-default-features --features sparse
cargo check --all-targets --no-default-features --features sparse,cache
cargo test
cargo test --all-features
cargo test --no-default-features
cargo test --no-default-features --features js_interop_tests
cargo test --no-default-features --features js_interop_tests,sparse
cargo test --no-default-features --features js_interop_tests,sparse,cache
cargo test --benches --no-default-features
test-windows:
runs-on: windows-latest

Expand All @@ -61,22 +56,17 @@ jobs:
components: rustfmt
- name: Run tests
run: |
cargo check --all-targets --no-default-features --features tokio
cargo check --all-targets --no-default-features --features tokio,sparse
cargo check --all-targets --no-default-features --features tokio,sparse,cache
cargo check --all-targets --no-default-features --features async-std
cargo check --all-targets --no-default-features --features async-std,sparse
cargo check --all-targets --no-default-features --features async-std,sparse,cache
cargo test --no-default-features --features tokio
cargo test --no-default-features --features tokio,shared-core
cargo test --no-default-features --features tokio,sparse
cargo test --no-default-features --features tokio,sparse,cache
cargo test --no-default-features --features async-std
cargo test --no-default-features --features async-std,shared-core
cargo test --no-default-features --features async-std,sparse
cargo test --no-default-features --features async-std,sparse,cache
cargo test --benches --no-default-features --features tokio
cargo test --benches --no-default-features --features async-std
cargo check --all-targets
cargo check --all-targets --all-features
cargo check --all-targets --no-default-features
cargo check --all-targets --no-default-features --features sparse
cargo check --all-targets --no-default-features --features sparse,cache
cargo test
cargo test --all-features
cargo test --no-default-features
cargo test --no-default-features --features sparse
cargo test --no-default-features --features sparse,cache
cargo test --benches --no-default-features

test-macos:
runs-on: macos-latest
Expand All @@ -88,22 +78,18 @@ jobs:
components: rustfmt
- name: Run tests
run: |
cargo check --all-targets --no-default-features --features tokio
cargo check --all-targets --no-default-features --features tokio,sparse
cargo check --all-targets --no-default-features --features tokio,sparse,cache
cargo check --all-targets --no-default-features --features async-std
cargo check --all-targets --no-default-features --features async-std,sparse
cargo check --all-targets --no-default-features --features async-std,sparse,cache
cargo test --no-default-features --features js_interop_tests,tokio
cargo test --no-default-features --features js_interop_tests,tokio,shared-core
cargo test --no-default-features --features js_interop_tests,tokio,sparse
cargo test --no-default-features --features js_interop_tests,tokio,sparse,cache
cargo test --no-default-features --features js_interop_tests,async-std
cargo test --no-default-features --features js_interop_tests,async-std,shared-core
cargo test --no-default-features --features js_interop_tests,async-std,sparse
cargo test --no-default-features --features js_interop_tests,async-std,sparse,cache
cargo test --benches --no-default-features --features tokio
cargo test --benches --no-default-features --features async-std
cargo check --all-targets
cargo check --all-targets --all-features
cargo check --all-targets --no-default-features
cargo check --all-targets --no-default-features --features sparse
cargo check --all-targets --no-default-features --features sparse,cache
cargo test
cargo test --all-features
cargo test --no-default-features
cargo test --no-default-features --features js_interop_tests
cargo test --no-default-features --features js_interop_tests,sparse
cargo test --no-default-features --features js_interop_tests,sparse,cache
cargo test --benches --no-default-features

build-extra:
runs-on: ubuntu-latest
Expand All @@ -115,24 +101,17 @@ jobs:
targets: wasm32-unknown-unknown
- name: Build WASM
run: |
cargo build --target=wasm32-unknown-unknown --no-default-features --features tokio
cargo build --target=wasm32-unknown-unknown --no-default-features --features async-std
cargo build --target=wasm32-unknown-unknown --no-default-features
- name: Build release
run: |
cargo build --release --no-default-features --features tokio
cargo build --release --no-default-features --features tokio,sparse
cargo build --release --no-default-features --features tokio,sparse,cache
cargo build --release --no-default-features --features async-std
cargo build --release --no-default-features --features async-std,sparse
cargo build --release --no-default-features --features async-std,sparse,cache
cargo build --release --no-default-features
cargo build --release --no-default-features --features sparse
cargo build --release --no-default-features --features sparse,cache
- name: Run examples
run: |
cargo run --no-default-features --features tokio --example disk
cargo run --no-default-features --features async-std --example disk
cargo run --no-default-features --features tokio --example memory
cargo run --no-default-features --features async-std --example memory
cargo run --no-default-features --features tokio --example replication
cargo run --no-default-features --features async-std --example replication
cargo run --no-default-features --example disk
cargo run --no-default-features --example memory
cargo run --no-default-features --example replication

lint:
runs-on: ubuntu-latest
Expand Down
35 changes: 23 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,34 @@ flat-tree = "6"
merkle-tree-stream = "0.12"
pretty-hash = "0.4"
rand = "0.8"
random-access-memory = "3"
random-access-storage = "5"
sha2 = "0.10"
futures = "0.3"
crc32fast = "1"
intmap = "2"
moka = { version = "0.12", optional = true, features = ["sync"] }
async-broadcast = { version = "0.7.1", optional = true }
async-lock = {version = "3.4.0", optional = true }
futures-lite = "2.6.1"

[dependencies.hypercore_schema]
version = "0.2.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
random-access-disk = { version = "3", default-features = false }
[dependencies.hypercore-protocol]
optional = true
path = "../protocol/"

[dependencies.hypercore_handshake]
version = "0.6.0"
optional = true

[dependencies.random-access-storage]
version = "6.0.0-alpha"

[dependencies.random-access-memory]
version = "4.0.0-alpha"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.random-access-disk]
version = "4.0.0-alpha"
default-features = false

[dev-dependencies]
anyhow = "1.0.70"
Expand All @@ -55,21 +68,19 @@ proptest-derive = "0.5.1"
data-encoding = "2.2.0"
remove_dir_all = "0.7.0"
tempfile = "3.1.0"
async-std = { version = "1.12.0", features = ["attributes"] }
tokio = { version = "1.27.0", default-features = false, features = ["macros", "rt", "rt-multi-thread"] }
tokio = { version = "1.27.0", default-features = false, features = ["macros", "rt", "rt-multi-thread", "io-util", "time"] }
tokio-util = { version = "0.7", features = ["compat"] }
uint24le_framing = { version = "0.2.0" }
tokio-test = "0.4"
sha2 = "0.10"
criterion = { version = "0.4", features = ["async_std", "async_tokio"] }
test-log = { version = "0.2.11", default-features = false, features = ["trace"] }
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "fmt"] }

[features]
default = ["tokio", "sparse", "replication", "cache"]
replication = ["dep:async-broadcast"]
shared-core = ["replication", "dep:async-lock"]
default = ["sparse", "replication", "cache"]
replication = ["dep:async-broadcast", "dep:hypercore-protocol", "dep:hypercore_handshake"]
sparse = ["random-access-disk/sparse"]
tokio = ["random-access-disk/tokio"]
async-std = ["random-access-disk/async-std"]
cache = ["moka"]
# Used only in interoperability tests under tests/js-interop which use the javascript version of hypercore
# to verify that this crate works. To run them, use:
Expand Down
19 changes: 0 additions & 19 deletions benches/disk.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::time::{Duration, Instant};

#[cfg(feature = "async-std")]
use criterion::async_executor::AsyncStdExecutor;
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use hypercore::{Hypercore, HypercoreBuilder, HypercoreError, Storage};
use tempfile::Builder as TempfileBuilder;
Expand All @@ -10,11 +8,6 @@ fn bench_create_disk(c: &mut Criterion) {
let mut group = c.benchmark_group("slow_call");
group.measurement_time(Duration::from_secs(20));

#[cfg(feature = "async-std")]
group.bench_function("create_disk", move |b| {
b.to_async(AsyncStdExecutor)
.iter(|| create_hypercore("create"));
});
#[cfg(feature = "tokio")]
group.bench_function("create_disk", move |b| {
let rt = tokio::runtime::Runtime::new().unwrap();
Expand Down Expand Up @@ -51,10 +44,6 @@ fn bench_write_disk(c: &mut Criterion) {
let mut group = c.benchmark_group("slow_call");
group.measurement_time(Duration::from_secs(20));

#[cfg(feature = "async-std")]
group.bench_function("write disk", |b| {
b.to_async(AsyncStdExecutor).iter_custom(write_disk);
});
#[cfg(feature = "tokio")]
group.bench_function("write disk", |b| {
let rt = tokio::runtime::Runtime::new().unwrap();
Expand All @@ -76,10 +65,6 @@ fn bench_read_disk(c: &mut Criterion) {
let mut group = c.benchmark_group("slow_call");
group.measurement_time(Duration::from_secs(20));

#[cfg(feature = "async-std")]
group.bench_function("read disk", |b| {
b.to_async(AsyncStdExecutor).iter_custom(read_disk);
});
#[cfg(feature = "tokio")]
group.bench_function("read disk", |b| {
let rt = tokio::runtime::Runtime::new().unwrap();
Expand All @@ -104,10 +89,6 @@ fn bench_clear_disk(c: &mut Criterion) {
let mut group = c.benchmark_group("slow_call");
group.measurement_time(Duration::from_secs(20));

#[cfg(feature = "async-std")]
group.bench_function("clear disk", |b| {
b.to_async(AsyncStdExecutor).iter_custom(clear_disk);
});
#[cfg(feature = "tokio")]
group.bench_function("clear disk", |b| {
let rt = tokio::runtime::Runtime::new().unwrap();
Expand Down
27 changes: 6 additions & 21 deletions benches/memory.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use std::time::{Duration, Instant};
use std::{
sync::Arc,
time::{Duration, Instant},
};

#[cfg(feature = "async-std")]
use criterion::async_executor::AsyncStdExecutor;
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use hypercore::{Hypercore, HypercoreBuilder, HypercoreError, Storage};
use random_access_memory::RandomAccessMemory;

fn bench_create_memory(c: &mut Criterion) {
#[cfg(feature = "async-std")]
c.bench_function("create memory", |b| {
b.to_async(AsyncStdExecutor).iter(|| create_hypercore(1024));
});
#[cfg(feature = "tokio")]
c.bench_function("create memory", |b| {
let rt = tokio::runtime::Runtime::new().unwrap();
Expand All @@ -25,7 +22,7 @@ async fn create_hypercore(page_size: usize) -> Result<Hypercore, HypercoreError>
let storage = Storage::open(
|_| {
Box::pin(async move {
Ok(Box::new(RandomAccessMemory::new(page_size)) as Box<dyn StorageTraits + Send>)
Ok(Arc::new(RandomAccessMemory::new(page_size)) as Arc<dyn StorageTraits>)
})
},
false,
Expand All @@ -44,7 +41,7 @@ async fn create_hypercore(page_size: usize) -> Result<Hypercore, HypercoreError>
let storage = Storage::open(
|_| {
Box::pin(async move {
Ok(Box::new(RandomAccessMemory::new(page_size)) as Box<dyn StorageTraits + Send>)
Ok(Arc::new(RandomAccessMemory::new(page_size)) as Arc<dyn StorageTraits>)
})
},
false,
Expand All @@ -54,10 +51,6 @@ async fn create_hypercore(page_size: usize) -> Result<Hypercore, HypercoreError>
}

fn bench_write_memory(c: &mut Criterion) {
#[cfg(feature = "async-std")]
c.bench_function("write memory", |b| {
b.to_async(AsyncStdExecutor).iter_custom(write_memory);
});
#[cfg(feature = "tokio")]
c.bench_function("write memory", |b| {
let rt = tokio::runtime::Runtime::new().unwrap();
Expand All @@ -76,10 +69,6 @@ async fn write_memory(iters: u64) -> Duration {
}

fn bench_read_memory(c: &mut Criterion) {
#[cfg(feature = "async-std")]
c.bench_function("read memory", |b| {
b.to_async(AsyncStdExecutor).iter_custom(read_memory);
});
#[cfg(feature = "tokio")]
c.bench_function("read memory", |b| {
let rt = tokio::runtime::Runtime::new().unwrap();
Expand All @@ -101,10 +90,6 @@ async fn read_memory(iters: u64) -> Duration {
}

fn bench_clear_memory(c: &mut Criterion) {
#[cfg(feature = "async-std")]
c.bench_function("clear memory", |b| {
b.to_async(AsyncStdExecutor).iter_custom(clear_memory);
});
#[cfg(feature = "tokio")]
c.bench_function("clear memory", |b| {
let rt = tokio::runtime::Runtime::new().unwrap();
Expand Down
6 changes: 1 addition & 5 deletions examples/disk.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#[cfg(feature = "async-std")]
use async_std::main as async_main;
use hypercore::{HypercoreBuilder, HypercoreError, Storage};
use tempfile::Builder;
#[cfg(feature = "tokio")]
use tokio::main as async_main;

/// Example about using an in-memory hypercore.
#[async_main]
#[tokio::main]
async fn main() {
// For the purposes of this example, first create a
// temporary directory to hold hypercore.
Expand Down
6 changes: 1 addition & 5 deletions examples/memory.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#[cfg(feature = "async-std")]
use async_std::main as async_main;
use hypercore::{HypercoreBuilder, HypercoreError, Storage};
#[cfg(feature = "tokio")]
use tokio::main as async_main;

/// Example about using an in-memory hypercore.
#[async_main]
#[tokio::main]
async fn main() {
// Create a memory storage
let storage = Storage::new_memory()
Expand Down
8 changes: 2 additions & 6 deletions examples/replication.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#[cfg(feature = "async-std")]
use async_std::main as async_main;
use hypercore::{Hypercore, HypercoreBuilder, HypercoreError, PartialKeypair, Storage};
use hypercore_schema::{RequestBlock, RequestUpgrade};
use tempfile::Builder;
#[cfg(feature = "tokio")]
use tokio::main as async_main;

/// Example on how to replicate a (disk) hypercore to another (memory) hypercore.
/// NB: The replication functions used here are low-level, built for use in the wire
/// protocol.
#[async_main]
#[tokio::main]
async fn main() {
// For the purposes of this example, first create a
// temporary directory to hold hypercore.
Expand Down Expand Up @@ -99,7 +95,7 @@ async fn replicate_index(
// Then the proof is verified and applied to the replicated party.
assert!(
replicated_hypercore
.verify_and_apply_proof(&proof)
.verify_and_apply_proof(proof)
.await
.expect("Verifying and applying proof failed")
);
Expand Down
Loading
Loading