Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add builder specific information #14

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , but we'll want to pin again once there's an appropriate tage on HotShot.

Copy link
Contributor

@QuentinI QuentinI Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't the plan to wait for new tag in HotShot before switching to BuilderCommitment?
cc: @nyospe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I think you are right. I missed the conversation.

serde = { version = "1.0", features = ["derive"] }
sha2 = "0.10"
snafu = { version = "0.7", features = ["backtraces"] }
Expand Down
28 changes: 21 additions & 7 deletions src/block_metadata.rs → src/block_info.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -33,11 +36,22 @@ impl<I: NodeType> Committable for HashableBlock<I> {
}
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
#[serde(bound = "")]
pub struct BlockMetadata<I: NodeType> {
block_hash: BlockHash<I>,
block_size: u64,
offered_fee: u64,
_phantom: PhantomData<I>,
pub struct AvailableBlockInfo<I: NodeType> {
pub block_hash: BuilderCommitment,
pub block_size: u64,
pub offered_fee: u64,
pub signature: <<I as NodeType>::SignatureKey as SignatureKey>::PureAssembledSignatureType,
pub sender: <I as NodeType>::SignatureKey,
pub _phantom: PhantomData<I>,
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
#[serde(bound = "")]
pub struct AvailableBlockData<I: NodeType> {
pub block_payload: <I as NodeType>::BlockPayload,
pub signature: <<I as NodeType>::SignatureKey as SignatureKey>::PureAssembledSignatureType,
pub sender: <I as NodeType>::SignatureKey,
pub _phantom: PhantomData<I>,
}
4 changes: 2 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -20,11 +21,11 @@ where
async fn get_available_blocks(
&self,
for_parent: &VidCommitment,
) -> Result<Vec<BlockMetadata<I>>, BuildError>;
) -> Result<Vec<AvailableBlockInfo<I>>, BuildError>;
async fn claim_block(
&self,
block_hash: &BlockHash<I>,
block_hash: &BuilderCommitment,
signature: &<<I as NodeType>::SignatureKey as SignatureKey>::PureAssembledSignatureType,
) -> Result<I::BlockPayload, BuildError>;
) -> Result<AvailableBlockData<I>, BuildError>;
async fn submit_txn(&self, txn: <I as NodeType>::Transaction) -> Result<(), BuildError>;
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 3 additions & 3 deletions src/query_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<I: NodeType> {
pub blocks: Vec<BlockMetadata<I>>,
pub blocks: Vec<AvailableBlockInfo<I>>,
}
Loading