Skip to content

Commit

Permalink
Merge pull request #611 from EspressoSystems/revert-610-revert-604-ho…
Browse files Browse the repository at this point in the history
…tshot/rc-0.5.56

[WEEKLY RELEASE] HotShot 0.5.56
  • Loading branch information
jparr721 authored Jun 3, 2024
2 parents bcfce9e + 9d13a74 commit d603779
Show file tree
Hide file tree
Showing 27 changed files with 1,142 additions and 871 deletions.
1,651 changes: 915 additions & 736 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[package]
name = "hotshot-query-service"
version = "0.1.29"
version = "0.1.30"
authors = ["Espresso Systems <hello@espressosys.com>"]
edition = "2021"
license = "GPL-3.0-or-later"
Expand Down Expand Up @@ -73,21 +73,21 @@ committable = "0.2"
custom_debug = "0.6"
derivative = "2.2"
derive_more = "0.99"
either = "1.11"
either = "1.12"
futures = "0.3"
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.55" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.55" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.55" }
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.56" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.56" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.56" }
itertools = "0.12.1"
jf-merkle-tree = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = ["std"] }
jf-vid = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = ["std", "parallel"] }
prometheus = "0.13"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
snafu = "0.8"
surf-disco = "0.6"
surf-disco = "0.7"
tagged-base64 = "0.4"
tide-disco = "0.6"
tide-disco = "0.7"
time = "0.3"
toml = "0.8"
tracing = "0.1"
Expand All @@ -112,7 +112,7 @@ tokio-postgres = { version = "0.7", optional = true, default-features = false, f

# 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.55", optional = true }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.56", optional = true }
portpicker = { version = "0.1", optional = true }
rand = { version = "0.8", optional = true }
spin_sleep = { version = "1.2", optional = true }
Expand All @@ -133,7 +133,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.55" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.56" }
portpicker = "0.1"
rand = "0.8"
reqwest = "0.12.3"
Expand Down
14 changes: 10 additions & 4 deletions examples/simple-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ use hotshot_query_service::{
},
Error,
};
use hotshot_testing::block_builder::{SimpleBuilderImplementation, TestBuilderImplementation};
use hotshot_testing::block_builder::{
SimpleBuilderConfig, SimpleBuilderImplementation, TestBuilderImplementation,
};
use hotshot_types::{
consensus::ConsensusMetricsValue, light_client::StateKeyPair, signature_key::BLSPubKey,
traits::election::Membership, ExecutionType, HotShotConfig, PeerConfig, ValidatorConfig,
Expand Down Expand Up @@ -169,8 +171,10 @@ async fn init_consensus(
};

// Start the builder server
let (builder_task, builder_url) =
<SimpleBuilderImplementation as TestBuilderImplementation<MockTypes>>::start(1, ()).await;
let (builder_task, builder_url) = <SimpleBuilderImplementation as TestBuilderImplementation<
MockTypes,
>>::start(1, SimpleBuilderConfig::default())
.await;

// Create the configuration
let config = HotShotConfig {
Expand Down Expand Up @@ -241,7 +245,9 @@ async fn init_consensus(
config,
memberships,
networks,
HotShotInitializer::from_genesis(TestInstanceState {}).unwrap(),
HotShotInitializer::from_genesis(TestInstanceState {})
.await
.unwrap(),
ConsensusMetricsValue::new(&*data_source.populate_metrics()),
storage,
)
Expand Down
7 changes: 4 additions & 3 deletions src/availability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn define_api<State, Types: NodeType, Ver: StaticVersionType + 'static>(
where
State: 'static + Send + Sync + ReadState,
<State as ReadState>::State: Send + Sync + AvailabilityDataSource<Types>,
Payload<Types>: QueryablePayload,
Payload<Types>: QueryablePayload<Types>,
{
let mut api = load_api::<State, Error, Ver>(
options.api_path.as_ref(),
Expand Down Expand Up @@ -474,7 +474,7 @@ mod test {
use async_std::sync::RwLock;
use committable::Committable;
use futures::future::FutureExt;
use hotshot_example_types::state_types::TestInstanceState;
use hotshot_example_types::state_types::{TestInstanceState, TestValidatedState};
use hotshot_types::{
constants::{Version01, STATIC_VER_0_1},
data::Leaf,
Expand Down Expand Up @@ -870,7 +870,8 @@ mod test {
);

// mock up some consensus data.
let leaf = Leaf::<MockTypes>::genesis(&TestInstanceState {});
let leaf =
Leaf::<MockTypes>::genesis(&TestValidatedState::default(), &TestInstanceState {}).await;

let block = BlockQueryData::new(leaf.block_header().clone(), MockPayload::genesis());

Expand Down
2 changes: 1 addition & 1 deletion src/availability/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<Types: NodeType> PartialOrd for BlockId<Types> {
#[async_trait]
pub trait AvailabilityDataSource<Types: NodeType>
where
Payload<Types>: QueryablePayload,
Payload<Types>: QueryablePayload<Types>,
{
type LeafRange<R>: Stream<Item = Fetch<LeafQueryData<Types>>> + Unpin + Send + 'static
where
Expand Down
53 changes: 34 additions & 19 deletions src/availability/query_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ pub type LeafHash<Types> = Commitment<Leaf<Types>>;
/// payload, so we can commit to the entire block simply by hashing the header.
pub type BlockHash<Types> = Commitment<Header<Types>>;
pub type TransactionHash<Types> = Commitment<Transaction<Types>>;
pub type TransactionIndex<Types> = <Payload<Types> as QueryablePayload>::TransactionIndex;
pub type TransactionInclusionProof<Types> = <Payload<Types> as QueryablePayload>::InclusionProof;
pub type TransactionIndex<Types> = <Payload<Types> as QueryablePayload<Types>>::TransactionIndex;
pub type TransactionInclusionProof<Types> =
<Payload<Types> as QueryablePayload<Types>>::InclusionProof;

pub type Timestamp = time::OffsetDateTime;

Expand All @@ -52,7 +53,7 @@ pub trait QueryableHeader<Types: NodeType>: BlockHeader<Types> {
/// the default implementations may be inefficient (e.g. performing an O(n) search, or computing an
/// unnecessary inclusion proof). It is good practice to override these default implementations if
/// your block type supports more efficient implementations (e.g. sublinear indexing by hash).
pub trait QueryablePayload: traits::BlockPayload {
pub trait QueryablePayload<Types: NodeType>: traits::BlockPayload<Types> {
/// An index which can be used to efficiently retrieve a transaction for the block.
///
/// This is left abstract so that different block implementations can index transactions
Expand Down Expand Up @@ -222,10 +223,13 @@ impl<Types: NodeType> LeafQueryData<Types> {
Ok(Self { leaf, qc })
}

pub fn genesis(instance_state: &Types::InstanceState) -> Self {
pub async fn genesis(
validated_state: &Types::ValidatedState,
instance_state: &Types::InstanceState,
) -> Self {
Self {
leaf: Leaf::genesis(instance_state),
qc: QuorumCertificate::genesis(instance_state),
leaf: Leaf::genesis(validated_state, instance_state).await,
qc: QuorumCertificate::genesis(validated_state, instance_state).await,
}
}

Expand Down Expand Up @@ -273,7 +277,7 @@ pub struct BlockQueryData<Types: NodeType> {
impl<Types: NodeType> BlockQueryData<Types> {
pub fn new(header: Header<Types>, payload: Payload<Types>) -> Self
where
Payload<Types>: QueryablePayload,
Payload<Types>: QueryablePayload<Types>,
{
Self {
hash: header.commit(),
Expand All @@ -284,11 +288,14 @@ impl<Types: NodeType> BlockQueryData<Types> {
}
}

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

Expand Down Expand Up @@ -323,7 +330,7 @@ impl<Types: NodeType> BlockQueryData<Types> {

impl<Types: NodeType> BlockQueryData<Types>
where
Payload<Types>: QueryablePayload,
Payload<Types>: QueryablePayload<Types>,
{
pub fn transaction(&self, ix: &TransactionIndex<Types>) -> Option<Transaction<Types>> {
self.payload().transaction(self.metadata(), ix)
Expand Down Expand Up @@ -380,11 +387,16 @@ impl<Types: NodeType> From<BlockQueryData<Types>> for PayloadQueryData<Types> {
}

impl<Types: NodeType> PayloadQueryData<Types> {
pub fn genesis(instance_state: &Types::InstanceState) -> Self
pub async fn genesis(
validated_state: &Types::ValidatedState,
instance_state: &Types::InstanceState,
) -> Self
where
Payload<Types>: QueryablePayload,
Payload<Types>: QueryablePayload<Types>,
{
BlockQueryData::genesis(instance_state).into()
BlockQueryData::genesis(validated_state, instance_state)
.await
.into()
}

pub fn hash(&self) -> VidCommitment {
Expand Down Expand Up @@ -429,8 +441,11 @@ impl<Types: NodeType> VidCommonQueryData<Types> {
}
}

pub fn genesis(instance_state: &Types::InstanceState) -> Self {
let leaf = Leaf::<Types>::genesis(instance_state);
pub async fn genesis(
validated_state: &Types::ValidatedState,
instance_state: &Types::InstanceState,
) -> Self {
let leaf = Leaf::<Types>::genesis(validated_state, instance_state).await;
let payload = leaf.block_payload().unwrap();
let bytes = payload.encode();
let disperse = vid_scheme(GENESIS_VID_NUM_STORAGE_NODES)
Expand Down Expand Up @@ -463,7 +478,7 @@ impl<Types: NodeType> HeightIndexed for VidCommonQueryData<Types> {
#[serde(bound = "")]
pub struct TransactionQueryData<Types: NodeType>
where
Payload<Types>: QueryablePayload,
Payload<Types>: QueryablePayload<Types>,
{
transaction: Transaction<Types>,
hash: TransactionHash<Types>,
Expand All @@ -475,7 +490,7 @@ where

impl<Types: NodeType> TransactionQueryData<Types>
where
Payload<Types>: QueryablePayload,
Payload<Types>: QueryablePayload<Types>,
{
pub(crate) fn new(
block: &BlockQueryData<Types>,
Expand Down Expand Up @@ -597,7 +612,7 @@ pub struct TransactionSummaryQueryData<Types: NodeType> {
// contentions.
impl<Types: NodeType> From<BlockQueryData<Types>> for BlockSummaryQueryData<Types>
where
Payload<Types>: QueryablePayload,
Payload<Types>: QueryablePayload<Types>,
{
fn from(value: BlockQueryData<Types>) -> Self {
BlockSummaryQueryData {
Expand Down
Loading

0 comments on commit d603779

Please sign in to comment.