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

General task architecture refactor #3133

Merged
merged 57 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
69fd4e2
refactor task trait
ss-es May 8, 2024
67a48bb
update interface
ss-es May 13, 2024
9bbec8c
update task-impls
ss-es May 14, 2024
b7a0ed3
update
ss-es May 16, 2024
edc12da
add arc into trait
ss-es May 17, 2024
21ed1c5
`hotshot` compiles
ss-es May 17, 2024
ee4d07a
cleanup
ss-es May 17, 2024
a22e33e
delete unused task functions
ss-es May 17, 2024
1d974cd
wip
ss-es May 20, 2024
436ce1f
compiles
ss-es May 20, 2024
15bced6
cleanup
ss-es May 21, 2024
b0a7472
fix tests
ss-es May 21, 2024
0832001
cleanup
ss-es May 21, 2024
02f6028
Merge branch 'main' into ss/task-structure-cleanup
ss-es May 21, 2024
6f55d60
cleanup
ss-es May 21, 2024
82ab241
wip
ss-es May 21, 2024
405d68a
fixes
ss-es May 21, 2024
1ea8bee
fixes
ss-es May 21, 2024
1e39948
fix
ss-es May 21, 2024
2773a88
shutdown networks as cleanup
ss-es May 21, 2024
22bbb25
fix?
ss-es May 22, 2024
7f2960a
fix
ss-es May 22, 2024
90faa9f
implement drop for request task
ss-es May 22, 2024
4bd0188
Merge branch 'main' into ss/task-structure-cleanup
ss-es May 22, 2024
d195c3b
try not canceling request subtask
ss-es May 22, 2024
abf21a6
fix??
ss-es May 22, 2024
2022ea7
cleanup
ss-es May 22, 2024
147bc73
partial revert
ss-es May 22, 2024
593e5ec
update vid task
ss-es May 22, 2024
fadc6fe
fix vid and view sync tests
ss-es May 22, 2024
9b655ed
remove harness
ss-es May 22, 2024
94dbb5a
fix multiple task unit test
ss-es May 22, 2024
025cf1e
fixes
ss-es May 22, 2024
76684e6
fix
ss-es May 22, 2024
45fd19e
shut down tasks when SystemContextHandle is dropped
ss-es May 23, 2024
103ca5d
Merge branch 'main' into ss/task-structure-cleanup
ss-es May 23, 2024
ecada5b
undo shutdown on drop
ss-es May 23, 2024
5322cbe
fix?
ss-es May 23, 2024
98dd48a
partially add boxsync futures
ss-es May 23, 2024
0e931a9
explicitly shutdown instead of dropping
ss-es May 23, 2024
17086f5
remove drop on request task
ss-es May 23, 2024
12f38e3
disable request subtask cancel
ss-es May 23, 2024
24b81ff
set shutdown flag for vid request subtask
ss-es May 24, 2024
1d5c434
shutdown consensus in handle
ss-es May 24, 2024
70b8c21
remove request delay
ss-es May 24, 2024
29170e0
fix flakiness with test outputs
ss-es May 24, 2024
abc4917
Merge branch 'main' into ss/task-structure-cleanup
ss-es May 24, 2024
1146873
add sleep to request do_vid loop
ss-es May 24, 2024
d494028
make SystemContextHandle unclonable
ss-es May 24, 2024
9fcf515
remove timeout on test runner shutdown
ss-es May 24, 2024
1318658
remove indirection in registry
ss-es May 24, 2024
089156d
remove network registry indirection
ss-es May 24, 2024
c3e4bb6
cleanup
ss-es May 24, 2024
38918a6
Merge branch 'main' into ss/task-structure-cleanup
ss-es May 27, 2024
85e7bf0
Merge branch 'main' into ss/task-structure-cleanup
ss-es May 27, 2024
2c98abb
Merge branch 'main' into ss/task-structure-cleanup
ss-es May 28, 2024
9208fb0
Merge branch 'main' into ss/task-structure-cleanup
ss-es May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ jobs:
name: Enable Rust Caching
with:
shared-key: "build-and-test"
prefix-key: ${{ matrix.just_variants }}
prefix-key: ${{ matrix.just_variants }}-${{ github.ref }}
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Install Just
run: |
Expand Down Expand Up @@ -119,9 +118,8 @@ jobs:
name: Enable Rust Caching
with:
shared-key: "build-and-test"
prefix-key: ${{ matrix.just_variants }}
prefix-key: ${{ matrix.just_variants }}-${{ github.ref }}
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Install Just
run: |
Expand Down Expand Up @@ -153,9 +151,8 @@ jobs:
name: Enable Rust Caching
with:
shared-key: "build-and-test"
prefix-key: ${{ matrix.just_variants }}
prefix-key: ${{ matrix.just_variants }}-${{ github.ref }}
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Install Just
run: |
Expand Down Expand Up @@ -197,9 +194,8 @@ jobs:
name: Enable Rust Caching
with:
shared-key: "build-and-test"
prefix-key: ${{ matrix.just_variants }}
prefix-key: ${{ matrix.just_variants }}-${{ github.ref }}
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Build examples in release mode
run: just ${{ matrix.just_variants }} build_release --examples --package hotshot-examples --no-default-features
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

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

165 changes: 23 additions & 142 deletions crates/hotshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ use async_lock::RwLock;
use async_trait::async_trait;
use committable::Committable;
use futures::join;
use hotshot_task::task::TaskRegistry;
use hotshot_task::task::{ConsensusTaskRegistry, NetworkTaskRegistry};
use hotshot_task_impls::{events::HotShotEvent, helpers::broadcast_event, network};
// Internal
/// Reexport error type
pub use hotshot_types::error::HotShotError;
use hotshot_types::{
consensus::{Consensus, ConsensusMetricsValue, View, ViewInner},
constants::{BASE_VERSION, EVENT_CHANNEL_SIZE, EXTERNAL_EVENT_CHANNEL_SIZE, STATIC_VER_0_1},
constants::{
Version01, BASE_VERSION, EVENT_CHANNEL_SIZE, EXTERNAL_EVENT_CHANNEL_SIZE, STATIC_VER_0_1,
},
data::Leaf,
event::{EventType, LeafInfo},
message::{DataMessage, Message, MessageKind},
Expand All @@ -53,22 +55,12 @@ use hotshot_types::{
// External
/// Reexport rand crate
pub use rand;
use tasks::{add_request_network_task, add_response_task, add_vid_task};
use tasks::{add_request_network_task, add_response_task};
use tracing::{debug, instrument, trace};
use vbs::version::Version;

#[cfg(not(feature = "dependency-tasks"))]
use crate::tasks::add_consensus_task;
#[cfg(feature = "dependency-tasks")]
use crate::tasks::{
add_consensus2_task, add_quorum_proposal_recv_task, add_quorum_proposal_task,
add_quorum_vote_task,
};
use crate::{
tasks::{
add_da_task, add_network_event_task, add_network_message_task, add_transaction_task,
add_upgrade_task, add_view_sync_task,
},
tasks::{add_consensus_tasks, add_network_event_task, add_network_message_task},
traits::NodeImplementation,
types::{Event, SystemContextHandle},
};
Expand Down Expand Up @@ -561,8 +553,8 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> SystemContext<TYPES, I> {
/// For a list of which tasks are being spawned, see this module's documentation.
#[allow(clippy::too_many_lines)]
pub async fn run_tasks(&self) -> SystemContextHandle<TYPES, I> {
// ED Need to set first first number to 1, or properly trigger the change upon start
let registry = Arc::new(TaskRegistry::default());
let consensus_registry = ConsensusTaskRegistry::new();
let network_registry = NetworkTaskRegistry::new();

let output_event_stream = self.external_event_stream.clone();
let internal_event_stream = self.internal_event_stream.clone();
Expand All @@ -574,171 +566,60 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> SystemContext<TYPES, I> {
let vid_membership = self.memberships.vid_membership.clone();
let view_sync_membership = self.memberships.view_sync_membership.clone();

let (event_tx, event_rx) = internal_event_stream.clone();

let handle = SystemContextHandle {
registry: Arc::clone(&registry),
let mut handle = SystemContextHandle {
consensus_registry,
network_registry,
output_event_stream: output_event_stream.clone(),
internal_event_stream: internal_event_stream.clone(),
hotshot: self.clone().into(),
storage: Arc::clone(&self.storage),
};

add_network_message_task(
Arc::clone(&registry),
event_tx.clone(),
Arc::clone(&quorum_network),
)
.await;
add_network_message_task(
Arc::clone(&registry),
event_tx.clone(),
Arc::clone(&da_network),
)
.await;
add_network_message_task(&mut handle, Arc::clone(&quorum_network)).await;
add_network_message_task(&mut handle, Arc::clone(&da_network)).await;

if let Some(request_rx) = da_network.spawn_request_receiver_task(STATIC_VER_0_1).await {
add_response_task(
Arc::clone(&registry),
event_rx.activate_cloned(),
request_rx,
&handle,
)
.await;
add_request_network_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
if let Some(request_receiver) = da_network.spawn_request_receiver_task(STATIC_VER_0_1).await
{
add_response_task(&mut handle, request_receiver).await;
add_request_network_task(&mut handle).await;
}

add_network_event_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&mut handle,
Arc::clone(&quorum_network),
quorum_membership.clone(),
network::quorum_filter,
Arc::clone(&handle.storage()),
)
.await;
add_network_event_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&mut handle,
Arc::clone(&quorum_network),
quorum_membership,
network::upgrade_filter,
Arc::clone(&handle.storage()),
)
.await;
add_network_event_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&mut handle,
Arc::clone(&da_network),
da_membership,
network::da_filter,
Arc::clone(&handle.storage()),
)
.await;
add_network_event_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&mut handle,
Arc::clone(&quorum_network),
view_sync_membership,
network::view_sync_filter,
Arc::clone(&handle.storage()),
)
.await;
add_network_event_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&mut handle,
Arc::clone(&quorum_network),
vid_membership,
network::vid_filter,
Arc::clone(&handle.storage()),
)
.await;
#[cfg(not(feature = "dependency-tasks"))]
add_consensus_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
add_da_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
add_vid_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
add_transaction_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
add_view_sync_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
add_upgrade_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
#[cfg(feature = "dependency-tasks")]
add_quorum_proposal_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
#[cfg(feature = "dependency-tasks")]
add_quorum_vote_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
#[cfg(feature = "dependency-tasks")]
add_quorum_proposal_recv_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
#[cfg(feature = "dependency-tasks")]
add_consensus2_task(
Arc::clone(&registry),
event_tx.clone(),
event_rx.activate_cloned(),
&handle,
)
.await;
add_consensus_tasks::<TYPES, I, Version01>(&mut handle).await;
handle
}
}
Expand Down