Skip to content

Commit

Permalink
Refactor: Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: shamb0 <r.raajey@gmail.com>

[Libp2p] DHT overhaul (#3548)

Update builder marketplace API (#3573)

Fix BuilderDataSource for marketplace builder (#3576)

* Fix BuilderDataSource for marketplace builder

Batch dependabot PRs (#3570)

Bump serde_json in the all group across 1 directory (#3579)

Fix upgrade lock in network task (#3580)

Bump the all group with 2 updates (#3582)

merge to upstream main

Signed-off-by: shamb0 <r.raajey@gmail.com>

Refactor: Address review comments

Signed-off-by: shamb0 <r.raajey@gmail.com>
  • Loading branch information
shamb0 committed Aug 16, 2024
1 parent 8411537 commit 02a3d4d
Show file tree
Hide file tree
Showing 27 changed files with 984 additions and 522 deletions.
11 changes: 9 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@ updates:
directory: "/"
schedule:
interval: daily
ignore:
- dependency-name: "hotshot-types"
groups:
all:
patterns:
- "*"
exclude-patterns:
- "cdn-*"
cdn:
patterns:
- "cdn-*"
28 changes: 20 additions & 8 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion crates/builder-api/api/v0_3/builder.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ DESCRIPTION = ""
FORMAT_VERSION = "0.1.0"

[route.bundle]
PATH = ["bundle/:view_number"]
PATH = ["bundle/:parent_view/:parent_hash/:view_number"]
":parent_view" = "Integer"
":parent_hash" = "TaggedBase64"
":view_number" = "Integer"
DOC = """
Fetch the bundle from the builder for the specified view.
Expand Down
13 changes: 10 additions & 3 deletions crates/builder-api/src/v0_3/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ where
api.with_version("0.0.3".parse().unwrap())
.get("bundle", |req, state| {
async move {
let parent_view = req.integer_param("parent_view")?;
let parent_hash = req.blob_param("parent_hash")?;
let view_number = req.integer_param("view_number")?;
state.bundle(view_number).await.context(BlockClaimSnafu {
resource: view_number.to_string(),
})
state
.bundle(parent_view, &parent_hash, view_number)
.await
.with_context(|_| BlockClaimSnafu {
resource: format!(
"Block for parent {parent_hash}@{parent_view} and view {view_number}"
),
})
}
.boxed()
})?
Expand Down
9 changes: 7 additions & 2 deletions crates/builder-api/src/v0_3/data_source.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_trait::async_trait;
use hotshot_types::{bundle::Bundle, traits::node_implementation::NodeType};
use hotshot_types::{bundle::Bundle, traits::node_implementation::NodeType, vid::VidCommitment};

use super::builder::BuildError;
/// No changes to these types
Expand All @@ -8,7 +8,12 @@ pub use crate::v0_1::data_source::AcceptsTxnSubmits;
#[async_trait]
pub trait BuilderDataSource<TYPES: NodeType> {
/// To get the list of available blocks
async fn bundle(&self, view_number: u64) -> Result<Bundle<TYPES>, BuildError>;
async fn bundle(
&self,
parent_view: u64,
parent_hash: &VidCommitment,
view_number: u64,
) -> Result<Bundle<TYPES>, BuildError>;

/// To get the builder's address
async fn builder_address(&self) -> Result<TYPES::BuilderSignatureKey, BuildError>;
Expand Down
2 changes: 1 addition & 1 deletion crates/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ surf-disco = { workspace = true }
time = { workspace = true }
derive_more = { workspace = true }
portpicker = "0.1"
lru = "0.12"
lru.workspace = true
hotshot-task = { path = "../task" }
hotshot = { path = "../hotshot" }
hotshot-example-types = { path = "../example-types" }
Expand Down
2 changes: 1 addition & 1 deletion crates/hotshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ hotshot-task-impls = { path = "../task-impls", version = "0.5.36", default-featu
hotshot-types = { path = "../types" }
libp2p-identity = { workspace = true }
libp2p-networking = { workspace = true }
lru = "0.12"
lru.workspace = true
portpicker = "0.1"
rand = { workspace = true }
serde = { workspace = true, features = ["rc"] }
Expand Down
6 changes: 2 additions & 4 deletions crates/hotshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,18 +637,16 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<T

handle
}
}

#[cfg(feature = "hotshot-testing")]
impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<TYPES, I, V> {
/// Creates a lightweight version of the system handle for task state testing.
///
/// This method provides a minimal context for task state tests, omitting the full
/// consensus and network task launches. It results in fewer traces and simplifies debugging.
///
/// # Returns
/// A `SystemContextHandle<TYPES, I, V>` with minimal setup for task state testing.
pub fn create_lean_test_handle(&self) -> SystemContextHandle<TYPES, I, V> {
#[cfg(feature = "hotshot-testing")]
pub fn build_inactive_handle(&self) -> SystemContextHandle<TYPES, I, V> {
let (internal_sender, internal_receiver) = broadcast(EVENT_CHANNEL_SIZE);

SystemContextHandle {
Expand Down
5 changes: 2 additions & 3 deletions crates/hotshot/src/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ use vbs::version::StaticVersionType;
use crate::{
tasks::task_state::CreateTaskState, types::SystemContextHandle, ConsensusApi,
ConsensusMetricsValue, ConsensusTaskRegistry, HotShotConfig, HotShotInitializer,
MarketplaceConfig, Memberships, NetworkTaskRegistry, SignatureKey, SystemContext, UpgradeLock,
Versions,
MarketplaceConfig, Memberships, NetworkTaskRegistry, SignatureKey, SystemContext, Versions,
};

/// event for global event stream
Expand Down Expand Up @@ -193,7 +192,7 @@ pub fn add_network_event_task<
membership,
filter,
storage: Arc::clone(&handle.storage()),
upgrade_lock: UpgradeLock::new(),
upgrade_lock: handle.hotshot.upgrade_lock.clone(),
};
let task = Task::new(
network_state,
Expand Down
Loading

0 comments on commit 02a3d4d

Please sign in to comment.