Skip to content

Commit

Permalink
Fix crypto bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
jparr721 committed Jan 31, 2025
1 parent 09bf698 commit 217f088
Show file tree
Hide file tree
Showing 27 changed files with 466 additions and 185 deletions.
311 changes: 248 additions & 63 deletions Cargo.lock

Large diffs are not rendered by default.

40 changes: 26 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,24 @@ tokio = { version = "1", default-features = false, features = [
"sync",
] }

hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
hotshot = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }
# Hotshot imports
hotshot-builder-api = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.5.84" }
marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.5.84" }
marketplace-builder-shared = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.5.84" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.58" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "v0.1.77" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "release-labrador-debug-2" }
marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "release-labrador-debug-2" }
marketplace-builder-shared = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "release-labrador-debug-2" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", branch = "release-labrador-debug-2" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", branch = "release-labrador-debug-2" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }
hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
libp2p-networking = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }
libp2p-networking = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }
hotshot-contract-adapter = { version = "0.1.0", path = "contracts/rust/adapter" }
# Temporary, used to pull in the mock auction results provider
hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.84" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "release-labrador-debug-2" }

# Push CDN imports
cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.5.1-upgrade", package = "cdn-broker" }
Expand Down Expand Up @@ -162,3 +162,15 @@ opt-level = 0
opt-level = 0
[profile.test.package.hotshot-state-prover]
opt-level = 3

# [patch."https://github.com/EspressoSystems/HotShot.git"]
# hotshot = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
# hotshot-builder-api = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
# hotshot-orchestrator = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
# hotshot-stake-table = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
# hotshot-task = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
# hotshot-task-impls = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
# hotshot-testing = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
# hotshot-types = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
# libp2p-networking = { git = "https://github.com/EspressoSystems//HotShot.git", branch = "release-labrador-debug-2" }
# hotshot-example-types = { git = "https://www.github.com/EspressoSystems/HotShot.git", branch = "release-labrador-debug-2" }
6 changes: 5 additions & 1 deletion builder/src/non_permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ impl BuilderConfig {

let vid_commitment = {
let payload_bytes = genesis_payload.encode();
vid_commitment(&payload_bytes, GENESIS_VID_NUM_STORAGE_NODES)
vid_commitment::<V>(
&payload_bytes,
GENESIS_VID_NUM_STORAGE_NODES,
<V as Versions>::Base::VERSION,
)
};

// create the global state
Expand Down
3 changes: 2 additions & 1 deletion node-metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = { workspace = true }
testing = ["serde_json", "espresso-types/testing"]

[dev-dependencies]
node-metrics = { path = ".", features = [ "testing" ] }
node-metrics = { path = ".", features = ["testing"] }

[dependencies]
async-lock = { workspace = true }
Expand All @@ -27,6 +27,7 @@ tokio = { workspace = true }

# Dependencies for feature `testing`
hotshot-types = { workspace = true }
hotshot-example-types = { workspace = true }
prometheus-parse = { version = "^0.2.5" }
reqwest = { workspace = true }
serde = { workspace = true }
Expand Down
8 changes: 6 additions & 2 deletions node-metrics/src/service/client_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ pub mod tests {
channel::mpsc::{self, Sender},
SinkExt, StreamExt,
};
use hotshot_example_types::node_types::TestVersions;
use hotshot_types::{signature_key::BLSPubKey, traits::signature_key::SignatureKey};
use std::{sync::Arc, time::Duration};
use tokio::{
Expand Down Expand Up @@ -1371,10 +1372,12 @@ pub mod tests {
async fn test_process_client_handling_stream_request_latest_blocks_snapshot() {
use super::clone_block_detail;
use crate::service::data_state::create_block_detail_from_leaf;
use hotshot_example_types::node_types::TestVersions;

let (_, _, _, mut data_state) = create_test_data_state();
let client_thread_state = Arc::new(RwLock::new(create_test_client_thread_state()));
let leaf_1 = Leaf::genesis(&ValidatedState::default(), &NodeState::mock()).await;
let leaf_1 =
Leaf::genesis::<TestVersions>(&ValidatedState::default(), &NodeState::mock()).await;
let block_1 = create_block_detail_from_leaf(&leaf_1);
data_state.add_latest_block(clone_block_detail(&block_1));

Expand Down Expand Up @@ -1614,7 +1617,8 @@ pub mod tests {
// No response expected from the client messages at the moment.

// send a new leaf
let leaf = Leaf::genesis(&ValidatedState::default(), &NodeState::mock()).await;
let leaf =
Leaf::genesis::<TestVersions>(&ValidatedState::default(), &NodeState::mock()).await;
let expected_block = create_block_detail_from_leaf(&leaf);
let arc_expected_block = Arc::new(expected_block);

Expand Down
3 changes: 2 additions & 1 deletion node-metrics/src/service/data_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ mod tests {
v0_99::ChainConfig, BlockMerkleTree, FeeMerkleTree, Leaf, NodeState, ValidatedState,
};
use futures::{channel::mpsc, SinkExt, StreamExt};
use hotshot_example_types::node_types::TestVersions;
use hotshot_types::{signature_key::BLSPubKey, traits::signature_key::SignatureKey};
use std::{sync::Arc, time::Duration};
use tokio::time::timeout;
Expand Down Expand Up @@ -627,7 +628,7 @@ mod tests {
};
let instance_state = NodeState::mock();

let sample_leaf = Leaf::genesis(&validated_state, &instance_state).await;
let sample_leaf = Leaf::genesis::<TestVersions>(&validated_state, &instance_state).await;

let mut leaf_sender = leaf_sender;
// We should be able to send a leaf without issue
Expand Down
15 changes: 9 additions & 6 deletions sequencer/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,17 +1084,19 @@ mod api_tests {
};
use ethers::utils::Anvil;
use futures::{future, stream::StreamExt};
use hotshot_example_types::node_types::TestVersions;
use hotshot_query_service::availability::{
AvailabilityDataSource, BlockQueryData, VidCommonQueryData,
};

use hotshot_types::data::vid_disperse::ADVZDisperseShare;
use hotshot_types::{
data::{DaProposal, QuorumProposal2, QuorumProposalWrapper, VidDisperseShare},
data::{DaProposal, QuorumProposal2, QuorumProposalWrapper},
event::LeafInfo,
message::Proposal,
simple_certificate::QuorumCertificate,
traits::{node_implementation::ConsensusTime, signature_key::SignatureKey, EncodeBytes},
vid::vid_scheme,
vid::advz_scheme,
};

use jf_vid::VidScheme;
Expand Down Expand Up @@ -1269,10 +1271,10 @@ mod api_tests {
// Create two non-consecutive leaf chains.
let mut chain1 = vec![];

let genesis = Leaf::genesis(&Default::default(), &NodeState::mock()).await;
let genesis = Leaf::genesis::<TestVersions>(&Default::default(), &NodeState::mock()).await;
let payload = genesis.block_payload().unwrap();
let payload_bytes_arc = payload.encode();
let disperse = vid_scheme(2).disperse(payload_bytes_arc.clone()).unwrap();
let disperse = advz_scheme(2).disperse(payload_bytes_arc.clone()).unwrap();
let payload_commitment = disperse.commit;
let mut quorum_proposal = QuorumProposalWrapper::<SeqTypes> {
proposal: QuorumProposal2::<SeqTypes> {
Expand Down Expand Up @@ -1323,7 +1325,7 @@ mod api_tests {
.unwrap();

// Include VID information for each leaf.
let share = VidDisperseShare::<SeqTypes> {
let share = ADVZDisperseShare::<SeqTypes> {
view_number: leaf.view_number(),
payload_commitment,
share: disperse.shares[0].clone(),
Expand Down Expand Up @@ -1471,7 +1473,8 @@ mod api_tests {
)
.await
.to_qc2();
let leaf = Leaf::genesis(&ValidatedState::default(), &NodeState::mock()).await;
let leaf =
Leaf::genesis::<TestVersions>(&ValidatedState::default(), &NodeState::mock()).await;

// Append the genesis leaf. We don't use this for the test, because the update function will
// automatically fill in the missing data for genesis. We just append this to get into a
Expand Down
10 changes: 5 additions & 5 deletions sequencer/src/block/full_payload/ns_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};
use hotshot_types::{
traits::EncodeBytes,
vid::{vid_scheme, LargeRangeProofType, VidCommitment, VidCommon, VidSchemeType},
vid::{advz_scheme, LargeRangeProofType, VidCommitment, VidCommon, VidSchemeType},
};
use jf_vid::{
payload_prover::{PayloadProver, Statement},
Expand Down Expand Up @@ -51,9 +51,9 @@ impl NsProof {
}
let ns_payload_range = payload.ns_table().ns_range(index, &payload_byte_len);

// TODO vid_scheme() arg should be u32 to match get_num_storage_nodes
// TODO advz_scheme() arg should be u32 to match get_num_storage_nodes
// https://github.com/EspressoSystems/HotShot/issues/3298
let vid = vid_scheme(
let vid = advz_scheme(
VidSchemeType::get_num_storage_nodes(common)
.try_into()
.ok()?, // error: failure to convert u32 to usize
Expand Down Expand Up @@ -105,9 +105,9 @@ impl NsProof {

match (&self.ns_proof, range.is_empty()) {
(Some(proof), false) => {
// TODO vid_scheme() arg should be u32 to match get_num_storage_nodes
// TODO advz_scheme() arg should be u32 to match get_num_storage_nodes
// https://github.com/EspressoSystems/HotShot/issues/3298
let vid = vid_scheme(
let vid = advz_scheme(
VidSchemeType::get_num_storage_nodes(common)
.try_into()
.ok()?, // error: failure to convert u32 to usize
Expand Down
2 changes: 1 addition & 1 deletion sequencer/src/block/full_payload/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl QueryablePayload<SeqTypes> for Payload {
// Need a `VidCommon` to proceed. Need to modify `QueryablePayload`
// trait to add a `VidCommon` arg. In the meantime tests fail if I leave
// it `todo!()`, so this hack allows tests to pass.
let common = hotshot_types::vid::vid_scheme(10)
let common = hotshot_types::vid::advz_scheme(10)
.disperse(&self.raw_payload)
.unwrap()
.common;
Expand Down
6 changes: 3 additions & 3 deletions sequencer/src/block/namespace_payload/tx_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
use hotshot_query_service::{VidCommitment, VidCommon};
use hotshot_types::{
traits::EncodeBytes,
vid::{vid_scheme, SmallRangeProofType, VidSchemeType},
vid::{advz_scheme, SmallRangeProofType, VidSchemeType},
};
use jf_vid::{
payload_prover::{PayloadProver, Statement},
Expand Down Expand Up @@ -73,7 +73,7 @@ impl TxProof {
let ns_range = payload.ns_table().ns_range(index.ns(), &payload_byte_len);
let ns_byte_len = ns_range.byte_len();
let ns_payload = payload.read_ns_payload(&ns_range);
let vid = vid_scheme(
let vid = advz_scheme(
VidSchemeType::get_num_storage_nodes(common)
.try_into()
.unwrap(),
Expand Down Expand Up @@ -161,7 +161,7 @@ impl TxProof {
return None; // error: tx index out of bounds
}

let vid = vid_scheme(
let vid = advz_scheme(
VidSchemeType::get_num_storage_nodes(common)
.try_into()
.unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions sequencer/src/block/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use hotshot::traits::BlockPayload;
use hotshot_query_service::availability::QueryablePayload;
use hotshot_types::{traits::EncodeBytes, vid::vid_scheme};
use hotshot_types::{traits::EncodeBytes, vid::advz_scheme};
use jf_vid::VidScheme;
use rand::RngCore;
use std::collections::HashMap;
Expand All @@ -26,7 +26,7 @@ async fn basic_correctness() {
let mut rng = jf_utils::test_rng();
let valid_tests = ValidTest::many_from_tx_lengths(test_cases, &mut rng);

let mut vid = vid_scheme(10);
let mut vid = advz_scheme(10);

for mut test in valid_tests {
let mut all_txs = test.all_txs();
Expand Down
7 changes: 6 additions & 1 deletion sequencer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ mod test {
use espresso_types::{Header, MockSequencerVersions, NamespaceId, Payload, Transaction};
use futures::StreamExt;
use hotshot::types::EventType::Decide;
use hotshot_example_types::node_types::TestVersions;
use hotshot_types::{
event::LeafInfo,
traits::block_contents::{
Expand Down Expand Up @@ -1148,7 +1149,11 @@ mod test {
let genesis_commitment = {
// TODO we should not need to collect payload bytes just to compute vid_commitment
let payload_bytes = genesis_payload.encode();
vid_commitment(&payload_bytes, GENESIS_VID_NUM_STORAGE_NODES)
vid_commitment::<TestVersions>(
&payload_bytes,
GENESIS_VID_NUM_STORAGE_NODES,
<TestVersions as Versions>::Base::VERSION,
)
};
let genesis_state = NodeState::mock();
Header::genesis(
Expand Down
11 changes: 6 additions & 5 deletions sequencer/src/message_compat_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use hotshot_types::{
traits::{
node_implementation::ConsensusTime, signature_key::SignatureKey, BlockPayload, EncodeBytes,
},
vid::vid_scheme,
vid::advz_scheme,
};
use jf_vid::VidScheme;
use pretty_assertions::assert_eq;
Expand All @@ -50,6 +50,7 @@ async fn test_message_compat<Ver: StaticVersionType>(_ver: Ver) {
use espresso_types::{EpochCommittees, Leaf, Payload, SeqTypes, Transaction};
use hotshot_example_types::node_types::TestVersions;
use hotshot_types::{
data::vid_disperse::{ADVZDisperse, ADVZDisperseShare},
simple_certificate::{
TimeoutCertificate, ViewSyncCommitCertificate, ViewSyncFinalizeCertificate,
ViewSyncPreCommitCertificate,
Expand Down Expand Up @@ -78,7 +79,7 @@ async fn test_message_compat<Ver: StaticVersionType>(_ver: Ver) {
old_version_last_view: ViewNumber::genesis(),
new_version_first_view: ViewNumber::genesis(),
};
let leaf = Leaf::genesis(
let leaf = Leaf::genesis::<TestVersions>(
&ValidatedState::default(),
&NodeState::mock().with_current_version(Ver::VERSION),
)
Expand Down Expand Up @@ -226,10 +227,10 @@ async fn test_message_compat<Ver: StaticVersionType>(_ver: Ver) {
Default::default(),
)),
DaConsensusMessage::VidDisperseMsg(Proposal {
data: VidDisperseShare::from_vid_disperse(
VidDisperse::from_membership(
data: ADVZDisperseShare::from_advz_disperse(
ADVZDisperse::from_membership(
ViewNumber::genesis(),
vid_scheme(1).disperse(payload.encode()).unwrap(),
advz_scheme(1).disperse(payload.encode()).unwrap(),
&membership,
Some(EpochNumber::genesis()),
Some(EpochNumber::new(1)),
Expand Down
Loading

0 comments on commit 217f088

Please sign in to comment.