Skip to content

Commit

Permalink
Merge pull request #532 from EspressoSystems/feat/load-whole-state
Browse files Browse the repository at this point in the history
Feat/load whole state
  • Loading branch information
jbearer authored Apr 17, 2024
2 parents 4f7db18 + d444389 commit 3df42e9
Show file tree
Hide file tree
Showing 7 changed files with 644 additions and 157 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ derive_more = "0.99"
either = "1.10"
futures = "0.3"
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.36" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.36" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.36" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.36" }
itertools = "0.12.1"
jf-primitives = { git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.3" }
prometheus = "0.13"
Expand Down Expand Up @@ -135,6 +135,6 @@ generic-array = "0.14"
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.36" }
portpicker = "0.1"
rand = "0.8"
reqwest = "0.12.3"
spin_sleep = "1.2"
tempfile = "3.10"
reqwest = "0.12.3"
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
RUST_BACKTRACE = 1;
RUST_LOG = "info";
RUSTFLAGS=" --cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"async-std\"";
RUSTFLAGS=" --cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"async-std\" --cfg hotshot_example";
# Use a distinct target dir for builds from within nix shells.
CARGO_TARGET_DIR = "target/nix";
in {
Expand Down
11 changes: 9 additions & 2 deletions src/data_source/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use crate::{
};
use async_trait::async_trait;
use hotshot_types::traits::node_implementation::NodeType;
use jf_primitives::merkle_tree::prelude::MerklePath;
use jf_primitives::merkle_tree::prelude::MerkleProof;
use std::ops::RangeBounds;

Expand Down Expand Up @@ -298,6 +297,14 @@ where
) -> QueryResult<MerkleProof<State::Entry, State::Key, State::T, ARITY>> {
self.data_source.get_path(snapshot, key).await
}

async fn keys(&self, snapshot: Snapshot<Types, State, ARITY>) -> QueryResult<Vec<State::Key>> {
self.data_source.keys(snapshot).await
}

async fn get_snapshot(&self, snapshot: Snapshot<Types, State, ARITY>) -> QueryResult<State> {
self.data_source.get_snapshot(snapshot).await
}
}

#[async_trait]
Expand Down Expand Up @@ -325,7 +332,7 @@ where
{
async fn insert_merkle_nodes(
&mut self,
path: MerklePath<State::Entry, State::Key, State::T>,
path: MerkleProof<State::Entry, State::Key, State::T, ARITY>,
traversal_path: Vec<usize>,
block_number: u64,
) -> QueryResult<()> {
Expand Down
26 changes: 22 additions & 4 deletions src/data_source/fetching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ use crate::{
Header, Payload, QueryResult, VidShare,
};
use anyhow::Context;
use jf_primitives::merkle_tree::prelude::MerkleProof;

use async_std::{
sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard},
task::sleep,
Expand All @@ -111,7 +109,7 @@ use futures::{
stream::{self, BoxStream, Stream, StreamExt},
};
use hotshot_types::traits::node_implementation::NodeType;
use jf_primitives::merkle_tree::{prelude::MerklePath, MerkleTreeScheme};
use jf_primitives::merkle_tree::{prelude::MerkleProof, MerkleTreeScheme};

use std::{
cmp::min,
Expand Down Expand Up @@ -560,7 +558,7 @@ where
{
async fn insert_merkle_nodes(
&mut self,
path: MerklePath<State::Entry, State::Key, State::T>,
path: MerkleProof<State::Entry, State::Key, State::T, ARITY>,
traversal_path: Vec<usize>,
block_number: u64,
) -> QueryResult<()> {
Expand Down Expand Up @@ -597,6 +595,26 @@ where
.get_path(snapshot, key)
.await
}

async fn keys(&self, snapshot: Snapshot<Types, State, ARITY>) -> QueryResult<Vec<State::Key>> {
self.fetcher
.storage
.read()
.await
.storage
.keys(snapshot)
.await
}

async fn get_snapshot(&self, snapshot: Snapshot<Types, State, ARITY>) -> QueryResult<State> {
self.fetcher
.storage
.read()
.await
.storage
.get_snapshot(snapshot)
.await
}
}

#[async_trait]
Expand Down
Loading

0 comments on commit 3df42e9

Please sign in to comment.