Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
import latest labrador
Browse files Browse the repository at this point in the history
  • Loading branch information
jparr721 committed Jan 31, 2025
1 parent 8eb2603 commit 4919999
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 45 deletions.
28 changes: 16 additions & 12 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ testing = [
"portpicker",
"rand",
"spin_sleep",
"tempfile"
"tempfile",
]

[[example]]
Expand All @@ -62,9 +62,9 @@ derivative = "2.2"
derive_more = "0.99"
either = "1.12"
futures = "0.3"
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.84" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.84" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.84" }
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
itertools = "0.12.1"
jf-merkle-tree = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"std",
Expand Down Expand Up @@ -115,7 +115,7 @@ sqlx = { version = "0.8", features = [

# Dependencies enabled by feature "testing".
espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0", optional = true }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.84", optional = true }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2", optional = true }
portpicker = { version = "0.1", optional = true }
rand = { version = "0.8", optional = true }
spin_sleep = { version = "1.2", optional = true }
Expand All @@ -136,7 +136,7 @@ backtrace-on-stack-overflow = { version = "0.3", optional = true }
clap = { version = "4.5", features = ["derive", "env"] }
espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0" }
generic-array = "0.14"
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.84" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
portpicker = "0.1"
rand = "0.8"
reqwest = "0.12.3"
Expand Down
18 changes: 9 additions & 9 deletions src/availability/query_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use hotshot_types::{
node_implementation::{NodeType, Versions},
EncodeBytes,
},
vid::{vid_scheme, VidCommitment},
vid::{advz_scheme, VidCommitment},
};
use jf_vid::VidScheme;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
Expand Down Expand Up @@ -239,7 +239,7 @@ impl<Types: NodeType> LeafQueryData<Types> {
instance_state: &Types::InstanceState,
) -> Self {
Self {
leaf: Leaf::genesis(validated_state, instance_state).await,
leaf: Leaf::genesis::<HsVer>(validated_state, instance_state).await,
qc: QuorumCertificate::genesis::<HsVer>(validated_state, instance_state).await,
}
}
Expand Down Expand Up @@ -302,14 +302,14 @@ impl<Types: NodeType> BlockQueryData<Types> {
}
}

pub async fn genesis(
pub async fn genesis<HsVer: Versions>(
validated_state: &Types::ValidatedState,
instance_state: &Types::InstanceState,
) -> Self
where
Payload<Types>: QueryablePayload<Types>,
{
let leaf = Leaf::<Types>::genesis(validated_state, instance_state).await;
let leaf = Leaf::<Types>::genesis::<HsVer>(validated_state, instance_state).await;
Self::new(leaf.block_header().clone(), leaf.block_payload().unwrap())
}

Expand Down Expand Up @@ -401,14 +401,14 @@ impl<Types: NodeType> From<BlockQueryData<Types>> for PayloadQueryData<Types> {
}

impl<Types: NodeType> PayloadQueryData<Types> {
pub async fn genesis(
pub async fn genesis<HsVer: Versions>(
validated_state: &Types::ValidatedState,
instance_state: &Types::InstanceState,
) -> Self
where
Payload<Types>: QueryablePayload<Types>,
{
BlockQueryData::genesis(validated_state, instance_state)
BlockQueryData::genesis::<HsVer>(validated_state, instance_state)
.await
.into()
}
Expand Down Expand Up @@ -455,14 +455,14 @@ impl<Types: NodeType> VidCommonQueryData<Types> {
}
}

pub async fn genesis(
pub async fn genesis<HsVer: Versions>(
validated_state: &Types::ValidatedState,
instance_state: &Types::InstanceState,
) -> Self {
let leaf = Leaf::<Types>::genesis(validated_state, instance_state).await;
let leaf = Leaf::<Types>::genesis::<HsVer>(validated_state, instance_state).await;
let payload = leaf.block_payload().unwrap();
let bytes = payload.encode();
let disperse = vid_scheme(GENESIS_VID_NUM_STORAGE_NODES)
let disperse = advz_scheme(GENESIS_VID_NUM_STORAGE_NODES)
.disperse(bytes)
.unwrap();

Expand Down
8 changes: 4 additions & 4 deletions src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ pub mod node_tests {
};
use hotshot_types::{
traits::block_contents::{vid_commitment, EncodeBytes},
vid::{vid_scheme, VidSchemeType},
vid::{advz_scheme, VidSchemeType},
};
use jf_vid::VidScheme;
use std::time::Duration;
Expand All @@ -803,7 +803,7 @@ pub mod node_tests {
let ds = D::connect(&storage).await;

// Set up a mock VID scheme to use for generating test data.
let mut vid = vid_scheme(2);
let mut vid = advz_scheme(2);

// Generate some mock leaves and blocks to insert.
let mut leaves = vec![
Expand Down Expand Up @@ -1069,7 +1069,7 @@ pub mod node_tests {
let ds = D::connect(&storage).await;

// Generate some test VID data.
let mut vid = vid_scheme(2);
let mut vid = advz_scheme(2);
let disperse = vid.disperse([]).unwrap();

// Insert test data with VID common and a share.
Expand Down Expand Up @@ -1137,7 +1137,7 @@ pub mod node_tests {
let commit = block.payload_hash();

// Set up a test VID scheme.
let vid = vid_scheme(network.num_nodes());
let vid = advz_scheme(network.num_nodes());

// Get VID common data and verify it.
tracing::info!("fetching common data");
Expand Down
4 changes: 2 additions & 2 deletions src/data_source/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ mod test {
testing::{consensus::DataSourceLifeCycle, mocks::MockTypes, setup_test},
};
use hotshot_example_types::state_types::{TestInstanceState, TestValidatedState};
use hotshot_types::vid::vid_scheme;
use hotshot_types::vid::advz_scheme;
use jf_vid::VidScheme;

type D = SqlDataSource<MockTypes, NoFetching>;
Expand All @@ -403,7 +403,7 @@ mod test {
let ds = <D as DataSourceLifeCycle>::connect(&storage).await;

// Generate some test VID data.
let disperse = vid_scheme(2).disperse([]).unwrap();
let disperse = advz_scheme(2).disperse([]).unwrap();

// Insert test data with VID common but no share.
let leaf = LeafQueryData::<MockTypes>::genesis::<TestVersions>(
Expand Down
29 changes: 19 additions & 10 deletions src/data_source/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ use anyhow::{ensure, Context};
use async_trait::async_trait;
use futures::future::Future;
use hotshot::types::{Event, EventType};
use hotshot_types::event::LeafInfo;
use hotshot_types::{data::VidDisperseShare, event::LeafInfo};
use hotshot_types::{
data::{Leaf, Leaf2, QuorumProposal},
traits::{
block_contents::{BlockHeader, BlockPayload, EncodeBytes, GENESIS_VID_NUM_STORAGE_NODES},
node_implementation::{ConsensusTime, NodeType},
},
vid::vid_scheme,
vid::advz_scheme,
};
use jf_vid::VidScheme;
use std::iter::once;
Expand Down Expand Up @@ -137,13 +137,22 @@ where
}

let (vid_common, vid_share) = if let Some(vid_share) = vid_share {
(
Some(VidCommonQueryData::new(
leaf.block_header().clone(),
vid_share.common.clone(),
)),
Some(vid_share.share.clone()),
)
match vid_share {
VidDisperseShare::V0(vid_share) => (
Some(VidCommonQueryData::new(
leaf.block_header().clone(),
vid_share.common.clone(),
)),
Some(vid_share.share.clone()),
),
VidDisperseShare::V1(vid_share) => (
Some(VidCommonQueryData::new(
leaf.block_header().clone(),
vid_share.common.clone(),
)),
Some(vid_share.share.clone()),
),
}
} else if leaf.view_number().u64() == 0 {
// HotShot does not run VID in consensus for the genesis block. In this case,
// the block payload is guaranteed to always be empty, so VID isn't really
Expand Down Expand Up @@ -181,7 +190,7 @@ fn genesis_vid<Types: NodeType>(
) -> anyhow::Result<(VidCommonQueryData<Types>, VidShare)> {
let payload = Payload::<Types>::empty().0;
let bytes = payload.encode();
let mut disperse = vid_scheme(GENESIS_VID_NUM_STORAGE_NODES)
let mut disperse = advz_scheme(GENESIS_VID_NUM_STORAGE_NODES)
.disperse(bytes)
.context("unable to compute VID dispersal for genesis block")?;
ensure!(
Expand Down
4 changes: 2 additions & 2 deletions src/fetching/provider/query_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use committable::Committable;
use futures::try_join;
use hotshot_types::{
traits::{node_implementation::NodeType, EncodeBytes},
vid::{vid_scheme, VidSchemeType},
vid::{advz_scheme, VidSchemeType},
};
use jf_vid::VidScheme;
use surf_disco::{Client, Url};
Expand Down Expand Up @@ -72,7 +72,7 @@ where
let num_storage_nodes =
VidSchemeType::get_num_storage_nodes(common.common()) as usize;
let bytes = payload.data().encode();
let commit = match vid_scheme(num_storage_nodes).commit_only(bytes) {
let commit = match advz_scheme(num_storage_nodes).commit_only(bytes) {
Ok(commit) => commit,
Err(err) => {
tracing::error!(%err, "unable to compute VID commitment");
Expand Down

0 comments on commit 4919999

Please sign in to comment.