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

Refactor demo and block payload implementations #1770

Merged
merged 7 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/hotshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ nll = { workspace = true }
rand = { workspace = true }
rand_chacha = { workspace = true }
serde = { workspace = true, features = ["rc"] }
sha3 = "^0.10"
snafu = { workspace = true }
surf-disco = { workspace = true }
time = { workspace = true }
Expand Down
17 changes: 7 additions & 10 deletions crates/hotshot/src/block_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ use std::{
use commit::{Commitment, Committable};
use hotshot_types::traits::{block_contents::Transaction, state::TestableBlock, BlockPayload};
use serde::{Deserialize, Serialize};
use sha3::{Digest, Keccak256};
use snafu::Snafu;

/// The transaction in a [`VIDBlockPayload`].
#[derive(PartialEq, Eq, Hash, Serialize, Deserialize, Clone, Debug)]
#[derive(Default, PartialEq, Eq, Hash, Serialize, Deserialize, Clone, Debug)]
pub struct VIDTransaction(pub Vec<u8>);

impl Committable for VIDTransaction {
fn commit(&self) -> Commitment<Self> {
// TODO: Use use VID block commitment.
// <https://github.com/EspressoSystems/HotShot/issues/1730>
commit::RawCommitmentBuilder::new("Txn Comm").finalize()
let builder = commit::RawCommitmentBuilder::new("Txn Comm");
let mut hasher = Keccak256::new();
hasher.update(self.0.clone());
shenkeyao marked this conversation as resolved.
Show resolved Hide resolved
let generic_array = hasher.finalize();
builder.generic_byte_array(&generic_array).finalize()
}

fn tag() -> String {
Expand All @@ -35,12 +38,6 @@ impl VIDTransaction {
}
}

impl Default for VIDTransaction {
fn default() -> Self {
Self::new()
}
}

/// The error type for block payload.
#[derive(Snafu, Debug)]
pub enum BlockPayloadError {
Expand Down
Loading