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

VID task and exchange #1903

Merged
merged 18 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 5 additions & 3 deletions crates/task-impls/src/vid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,16 @@ where
}

#[instrument(skip_all, fields(id = state.id, view = *state.cur_view), name = "VID Vote Collection Task", level = "error")]
async fn vote_handle<TYPES: NodeType, I: NodeImplementation<TYPES, Leaf = SequencingLeaf<TYPES>>>(
async fn vote_handle<TYPES, I>(
mut state: VIDVoteCollectionTaskState<TYPES, I>,
event: SequencingHotShotEvent<TYPES, I>,
) -> (
std::option::Option<HotShotTaskCompleted>,
Option<HotShotTaskCompleted>,
VIDVoteCollectionTaskState<TYPES, I>,
)
where
TYPES: NodeType,
I: NodeImplementation<TYPES, Leaf = SequencingLeaf<TYPES>>,
VIDEx<TYPES, I>: ConsensusExchange<
TYPES,
Message<TYPES, I>,
Expand Down Expand Up @@ -398,7 +400,7 @@ where
}
}

/// task state implementation for DA Task
/// task state implementation for VID Task
impl<
TYPES: NodeType,
I: NodeImplementation<
Expand Down
13 changes: 7 additions & 6 deletions crates/testing/tests/vid_task.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use commit::Committable;
use hotshot::{tasks::add_vid_task, HotShotSequencingConsensusApi};
use hotshot::{
tasks::add_vid_task,
types::{bn254::BLSPubKey, SignatureKey},
HotShotSequencingConsensusApi,
};
use hotshot_task_impls::events::SequencingHotShotEvent;
use hotshot_testing::{
node_types::{SequencingMemoryImpl, SequencingTestTypes},
task_helpers::vid_init,
};
use hotshot_types::traits::election::CommitteeExchangeType;
use hotshot_types::traits::election::VIDExchangeType;
use hotshot_types::{
block_impl::VIDTransaction,
Expand Down Expand Up @@ -37,8 +40,8 @@ async fn test_vid_task() {
inner: handle.hotshot.inner.clone(),
};
let vid_exchange = api.inner.exchanges.vid_exchange().clone();
let committee_exchange = api.inner.exchanges.committee_exchange().clone();
let pub_key = *api.public_key();
let priv_key = api.private_key();
let vid = vid_init();
let txn = vec![0u8];
let vid_disperse = vid.disperse(&txn).unwrap();
Expand All @@ -48,7 +51,7 @@ async fn test_vid_task() {
commitment: block_commitment,
};

let signature = committee_exchange.sign_da_proposal(&block.commit());
let signature = BLSPubKey::sign(priv_key, block.commit().as_ref());
rob-maron marked this conversation as resolved.
Show resolved Hide resolved
let proposal: DAProposal<SequencingTestTypes> = DAProposal {
deltas: block.clone(),
view_number: ViewNumber::new(2),
Expand All @@ -66,8 +69,6 @@ async fn test_vid_task() {
},
signature: message.signature.clone(),
};
// TODO for now reuse the same block commitment and signature as DA committee
// https://github.com/EspressoSystems/jellyfish/issues/369

// Every event input is seen on the event stream in the output.
let mut input = Vec::new();
Expand Down
8 changes: 7 additions & 1 deletion crates/types/src/traits/node_implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,12 @@ pub struct SequencingExchanges<
// https://github.com/EspressoSystems/HotShot/issues/1799
#[allow(clippy::type_complexity)]

pub timeout_exchange: TimeoutExchange<TYPES, <<SequencingExchanges<TYPES, MESSAGE, QUORUMEXCHANGE, COMMITTEEEXCHANGE, VIEWSYNCEXCHANGE, VIDEXCHANGE> as ExchangesType<TYPES, SequencingLeaf<TYPES>, MESSAGE>>::QuorumExchange as ConsensusExchange<TYPES, MESSAGE>>::Proposal, <<SequencingExchanges<TYPES, MESSAGE, QUORUMEXCHANGE, COMMITTEEEXCHANGE, VIEWSYNCEXCHANGE, VIDEXCHANGE> as ExchangesType<TYPES, SequencingLeaf<TYPES>, MESSAGE>>::QuorumExchange as ConsensusExchange<TYPES, MESSAGE>>::Membership, <QUORUMEXCHANGE as ConsensusExchange<TYPES, MESSAGE>>::Networking, MESSAGE>,
pub timeout_exchange: TimeoutExchange<TYPES, <<SequencingExchanges<TYPES, MESSAGE, QUORUMEXCHANGE, COMMITTEEEXCHANGE, VIEWSYNCEXCHANGE, VIDEXCHANGE>
as ExchangesType<TYPES, SequencingLeaf<TYPES>, MESSAGE>>::QuorumExchange
as ConsensusExchange<TYPES, MESSAGE>>::Proposal, <<SequencingExchanges<TYPES, MESSAGE, QUORUMEXCHANGE, COMMITTEEEXCHANGE, VIEWSYNCEXCHANGE, VIDEXCHANGE>
as ExchangesType<TYPES, SequencingLeaf<TYPES>, MESSAGE>>::QuorumExchange
as ConsensusExchange<TYPES, MESSAGE>>::Membership, <QUORUMEXCHANGE
as ConsensusExchange<TYPES, MESSAGE>>::Networking, MESSAGE>,

/// Phantom data
_phantom: PhantomData<(TYPES, MESSAGE)>,
Expand Down Expand Up @@ -348,6 +353,7 @@ where
);

// RM TODO: figure out if this is the proper config
// issue: https://github.com/EspressoSystems/HotShot/issues/1918
let vid_exchange = VIDEXCHANGE::create(entries, configs.1, networks.3, pk, entry, sk);

Self {
Expand Down