diff --git a/Cargo.toml b/Cargo.toml index 1df9730..7c86fbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ clap = { version = "4.4", features = ["derive", "env"] } commit = { git = "https://github.com/EspressoSystems/commit.git" } derive_more = "0.99" futures = "0.3" -hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.7.1" } +#hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.7.1" } +hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "main" } serde = { version = "1.0", features = ["derive"] } sha2 = "0.10" snafu = { version = "0.7", features = ["backtraces"] } diff --git a/src/block_metadata.rs b/src/block_info.rs similarity index 56% rename from src/block_metadata.rs rename to src/block_info.rs index ff7784e..fee3537 100644 --- a/src/block_metadata.rs +++ b/src/block_info.rs @@ -1,7 +1,10 @@ use std::{hash::Hash, marker::PhantomData}; use commit::{Commitment, Committable}; -use hotshot_types::traits::{node_implementation::NodeType, BlockPayload}; +use hotshot_types::{ + traits::{node_implementation::NodeType, BlockPayload, signature_key::SignatureKey}, + utils::BuilderCommitment +}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; @@ -33,11 +36,22 @@ impl Committable for HashableBlock { } } -#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)] #[serde(bound = "")] -pub struct BlockMetadata { - block_hash: BlockHash, - block_size: u64, - offered_fee: u64, - _phantom: PhantomData, +pub struct AvailableBlockInfo { + pub block_hash: BuilderCommitment, + pub block_size: u64, + pub offered_fee: u64, + pub signature: <::SignatureKey as SignatureKey>::PureAssembledSignatureType, + pub sender: ::SignatureKey, + pub _phantom: PhantomData, +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)] +#[serde(bound = "")] +pub struct AvailableBlockData { + pub block_payload: ::BlockPayload, + pub signature: <::SignatureKey as SignatureKey>::PureAssembledSignatureType, + pub sender: ::SignatureKey, + pub _phantom: PhantomData, } diff --git a/src/builder.rs b/src/builder.rs index bcda68e..775b709 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -3,7 +3,7 @@ use std::{fmt::Display, path::PathBuf}; use clap::Args; use derive_more::From; use futures::FutureExt; -use hotshot_types::traits::{node_implementation::NodeType, signature_key::SignatureKey}; +use hotshot_types::{traits::{node_implementation::NodeType, signature_key::SignatureKey}, utils::BuilderCommitment}; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tagged_base64::TaggedBase64; @@ -95,7 +95,7 @@ where })? .get("claim_block", |req, state| { async move { - let hash = req.blob_param("block_hash")?; + let hash:BuilderCommitment = req.blob_param("block_hash")?; let signature = req.blob_param("signature")?; state .claim_block(&hash, &signature) diff --git a/src/data_source.rs b/src/data_source.rs index df207d5..8b15b0b 100644 --- a/src/data_source.rs +++ b/src/data_source.rs @@ -2,11 +2,12 @@ use async_trait::async_trait; use hotshot_types::{ data::VidCommitment, traits::{node_implementation::NodeType, signature_key::SignatureKey}, + utils::BuilderCommitment }; use tagged_base64::TaggedBase64; use crate::{ - block_metadata::{BlockHash, BlockMetadata}, + block_info::{AvailableBlockInfo, AvailableBlockData}, builder::BuildError, }; @@ -20,11 +21,11 @@ where async fn get_available_blocks( &self, for_parent: &VidCommitment, - ) -> Result>, BuildError>; + ) -> Result>, BuildError>; async fn claim_block( &self, - block_hash: &BlockHash, + block_hash: &BuilderCommitment, signature: &<::SignatureKey as SignatureKey>::PureAssembledSignatureType, - ) -> Result; + ) -> Result, BuildError>; async fn submit_txn(&self, txn: ::Transaction) -> Result<(), BuildError>; } diff --git a/src/lib.rs b/src/lib.rs index 8a52c67..c89608d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ mod api; -pub mod block_metadata; +pub mod block_info; pub mod builder; pub mod data_source; pub mod query_data; diff --git a/src/query_data.rs b/src/query_data.rs index 602a329..44b2d1c 100644 --- a/src/query_data.rs +++ b/src/query_data.rs @@ -6,10 +6,10 @@ use hotshot_types::traits::node_implementation::NodeType; use serde::{Deserialize, Serialize}; -use crate::block_metadata::BlockMetadata; +use crate::block_info::AvailableBlockInfo; -#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq, Hash)] #[serde(bound = "")] pub struct AvailableBlocksQueryData { - pub blocks: Vec>, + pub blocks: Vec>, }