Skip to content

Commit

Permalink
Merge branch 'main' into keyao/drb-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
shenkeyao committed Nov 14, 2024
2 parents 3f5be42 + 9a3aba6 commit 078859e
Show file tree
Hide file tree
Showing 64 changed files with 762 additions and 884 deletions.
285 changes: 111 additions & 174 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ anyhow = "1"


# Push CDN imports
cdn-client = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.4.7" }
cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.4.7" }
cdn-marshal = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.4.7" }
cdn-proto = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.4.7" }
cdn-client = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.5.1" }
cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.5.1" }
cdn-marshal = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.5.1" }
cdn-proto = { git = "https://github.com/EspressoSystems/Push-CDN", tag = "0.5.1" }

### Profiles
###
Expand Down
12 changes: 8 additions & 4 deletions crates/builder-api/src/v0_1/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ pub fn submit_api<State, Types: NodeType, Ver: StaticVersionType + 'static>(
options: &Options,
) -> Result<Api<State, Error, Ver>, ApiError>
where
State: 'static + Send + Sync + AcceptsTxnSubmits<Types>,
State: 'static + Send + Sync + ReadState,
<State as ReadState>::State: Send + Sync + AcceptsTxnSubmits<Types>,
{
let mut api = load_api::<State, Error, Ver>(
options.api_path.as_ref(),
Expand All @@ -234,7 +235,7 @@ where
.map_err(Error::TxnUnpack)?;
let hash = tx.commit();
state
.submit_txns(vec![tx])
.read(|state| state.submit_txns(vec![tx]))
.await
.map_err(Error::TxnSubmit)?;
Ok(hash)
Expand All @@ -247,12 +248,15 @@ where
.body_auto::<Vec<<Types as NodeType>::Transaction>, Ver>(Ver::instance())
.map_err(Error::TxnUnpack)?;
let hashes = txns.iter().map(|tx| tx.commit()).collect::<Vec<_>>();
state.submit_txns(txns).await.map_err(Error::TxnSubmit)?;
state
.read(|state| state.submit_txns(txns))
.await
.map_err(Error::TxnSubmit)?;
Ok(hashes)
}
.boxed()
})?
.at("get_status", |req: RequestParams, state| {
.get("get_status", |req: RequestParams, state| {
async move {
let tx = req
.body_auto::<<Types as NodeType>::Transaction, Ver>(Ver::instance())
Expand Down
8 changes: 0 additions & 8 deletions crates/example-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,19 @@ slow-tests = []
gpu-vid = ["hotshot-task-impls/gpu-vid"]

[dependencies]
async-broadcast = { workspace = true }
async-trait = { workspace = true }
anyhow = { workspace = true }
sha3 = "^0.10"
committable = { workspace = true }
either = { workspace = true }
futures = { workspace = true }
hotshot = { path = "../hotshot" }
hotshot-types = { path = "../types" }
hotshot-task-impls = { path = "../task-impls", version = "0.5.36", default-features = false }
hotshot-builder-api = { path = "../builder-api" }
rand = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
serde = { workspace = true }
sha2 = { workspace = true }
time = { workspace = true }
async-lock = { workspace = true }
bitvec = { workspace = true }
ethereum-types = { workspace = true }
hotshot-task = { path = "../task" }
jf-vid = { workspace = true }
vbs = { workspace = true }
url = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/example-types/src/block_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ impl<
builder_commitment: BuilderCommitment,
metadata: <TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata,
_builder_fee: Vec<BuilderFee<TYPES>>,
_view_number: u64,
_vid_common: VidCommon,
_auction_results: Option<TYPES::AuctionResult>,
_version: Version,
Expand Down
1 change: 1 addition & 0 deletions crates/example-types/src/state_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl<TYPES: NodeType> ValidatedState<TYPES> for TestValidatedState {
_proposed_header: &TYPES::BlockHeader,
_vid_common: VidCommon,
_version: Version,
_view_number: u64,
) -> Result<(Self, Self::Delta), Self::Error> {
Self::run_delay_settings_from_config(&instance.delay_config).await;
Ok((
Expand Down
5 changes: 5 additions & 0 deletions crates/example-types/src/storage_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct TestStorageState<TYPES: NodeType> {
proposals: BTreeMap<TYPES::View, Proposal<TYPES, QuorumProposal<TYPES>>>,
high_qc: Option<hotshot_types::simple_certificate::QuorumCertificate<TYPES>>,
action: TYPES::View,
epoch: TYPES::Epoch,
}

impl<TYPES: NodeType> Default for TestStorageState<TYPES> {
Expand All @@ -52,6 +53,7 @@ impl<TYPES: NodeType> Default for TestStorageState<TYPES> {
proposals: BTreeMap::new(),
high_qc: None,
action: TYPES::View::genesis(),
epoch: TYPES::Epoch::genesis(),
}
}
}
Expand Down Expand Up @@ -101,6 +103,9 @@ impl<TYPES: NodeType> TestStorage<TYPES> {
pub async fn last_actioned_view(&self) -> TYPES::View {
self.inner.read().await.action
}
pub async fn last_actioned_epoch(&self) -> TYPES::Epoch {
self.inner.read().await.epoch
}
}

#[async_trait]
Expand Down
21 changes: 1 addition & 20 deletions crates/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ rust-version = { workspace = true }
default = ["docs", "doc-images", "hotshot-testing"]
gpu-vid = ["hotshot-task-impls/gpu-vid"]

# Features required for binaries
bin-orchestrator = ["clap"]

# Build the extended documentation
docs = []
doc-images = []
Expand Down Expand Up @@ -81,51 +78,35 @@ name = "whitelist-push-cdn"
path = "push-cdn/whitelist-adapter.rs"

[dependencies]
async-broadcast = { workspace = true }
async-lock = { workspace = true }
async-trait = { workspace = true }
bimap = "0.6"
clap = { workspace = true, optional = true }
committable = { workspace = true }
custom_debug = { workspace = true }
dashmap = "6"
either = { workspace = true }
futures = { workspace = true }
hotshot-orchestrator = { version = "0.5.36", path = "../orchestrator", default-features = false }
hotshot-types = { path = "../types" }
hotshot-testing = { path = "../testing" }
hotshot-task-impls = { path = "../task-impls", version = "0.5.36", default-features = false }
libp2p-identity = { workspace = true }
hotshot-task-impls = { path = "../task-impls" }
libp2p-networking = { workspace = true }
rand = { workspace = true }
serde = { workspace = true, features = ["rc"] }
thiserror = { workspace = true }
surf-disco = { workspace = true }
time = { workspace = true }
derive_more = { workspace = true }
portpicker.workspace = true
lru.workspace = true
hotshot-task = { path = "../task" }
hotshot = { path = "../hotshot" }
hotshot-example-types = { path = "../example-types" }
chrono = { workspace = true }
vbs = { workspace = true }
sha2.workspace = true
local-ip-address = "0.6"
vec1 = { workspace = true }
url = { workspace = true }

tracing = { workspace = true }
tokio = { workspace = true }

cdn-client = { workspace = true }
cdn-broker = { workspace = true, features = ["global-permits"] }
cdn-marshal = { workspace = true }

[dev-dependencies]
clap.workspace = true
toml = { workspace = true }
blake3 = { workspace = true }
anyhow.workspace = true
tracing-subscriber = "0.3"

Expand Down
5 changes: 4 additions & 1 deletion crates/examples/combined/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod types;

use std::path::Path;

use cdn_broker::Broker;
use cdn_broker::{reexports::def::hook::NoMessageHook, Broker};
use cdn_marshal::Marshal;
use hotshot::{
helpers::initialize_logging,
Expand Down Expand Up @@ -82,6 +82,9 @@ async fn main() {
private_key: broker_private_key.clone(),
},

user_message_hook: NoMessageHook,
broker_message_hook: NoMessageHook,

metrics_bind_endpoint: None,
ca_cert_path: None,
ca_key_path: None,
Expand Down
15 changes: 12 additions & 3 deletions crates/examples/push-cdn/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ pub mod types;

use std::path::Path;

use cdn_broker::{reexports::crypto::signature::KeyPair, Broker};
use cdn_broker::{
reexports::{crypto::signature::KeyPair, def::hook::NoMessageHook},
Broker,
};

use cdn_marshal::Marshal;
use hotshot::{
helpers::initialize_logging,
Expand Down Expand Up @@ -90,6 +94,9 @@ async fn main() {
private_key: broker_private_key.clone(),
},

user_message_hook: NoMessageHook,
broker_message_hook: NoMessageHook,

metrics_bind_endpoint: None,
ca_cert_path: None,
ca_key_path: None,
Expand All @@ -109,10 +116,12 @@ async fn main() {
}

// Get the port to use for the marshal
let marshal_port = 9000;
let marshal_endpoint = config
.cdn_marshal_address
.clone()
.expect("CDN marshal address must be specified");

// Configure the marshal
let marshal_endpoint = format!("127.0.0.1:{marshal_port}");
let marshal_config = cdn_marshal::Config {
bind_endpoint: marshal_endpoint.clone(),
discovery_endpoint,
Expand Down
7 changes: 5 additions & 2 deletions crates/examples/push-cdn/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! The following is the main `Broker` binary, which just instantiates and runs
//! a `Broker` object.
use anyhow::Result;
use cdn_broker::{Broker, Config};
use cdn_broker::{reexports::def::hook::NoMessageHook, Broker, Config};
use clap::Parser;
use hotshot::traits::implementations::{KeyPair, ProductionDef, WrappedSignatureKey};
use hotshot_example_types::node_types::TestTypes;
Expand Down Expand Up @@ -103,6 +103,9 @@ async fn main() -> Result<()> {
private_key,
},

user_message_hook: NoMessageHook,
broker_message_hook: NoMessageHook,

public_bind_endpoint: args.public_bind_endpoint,
public_advertise_endpoint: args.public_advertise_endpoint,
private_bind_endpoint: args.private_bind_endpoint,
Expand All @@ -111,7 +114,7 @@ async fn main() -> Result<()> {
};

// Create new `Broker`
// Uses TCP from broker connections and Quic for user connections.
// Uses TCP from broker connections and TCP+TLS for user connections.
let broker = Broker::new(broker_config).await?;

// Start the main loop, consuming it
Expand Down
2 changes: 0 additions & 2 deletions crates/fakeapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ tokio = { workspace = true }
anyhow = { workspace = true }
hotshot-types = { path = "../types" }
vbs = { workspace = true }
serde = { workspace = true }
rand = { workspace = true }
hotshot-example-types = { path = "../example-types" }
async-trait = { workspace = true }
futures = { workspace = true }
async-lock = { workspace = true }
tracing = { workspace = true }

[lints]
workspace = true
11 changes: 0 additions & 11 deletions crates/hotshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ example-upgrade = ["hotshot-task-impls/example-upgrade"]
gpu-vid = ["hotshot-task-impls/gpu-vid"]
rewind = ["hotshot-task-impls/rewind"]

# Features required for binaries
bin-orchestrator = ["clap"]

# Build the extended documentation
docs = []
doc-images = []
Expand All @@ -29,11 +26,9 @@ async-trait = { workspace = true }
bimap = "0.6"
bincode = { workspace = true }
chrono = { workspace = true }
clap = { workspace = true, optional = true }
committable = { workspace = true }
custom_debug = { workspace = true }
dashmap = "6"
derive_more = { workspace = true }
either = { workspace = true }
ethereum-types = { workspace = true }
futures = { workspace = true }
Expand All @@ -46,15 +41,11 @@ lru.workspace = true
portpicker = "0.1"
rand = { workspace = true }
serde = { workspace = true, features = ["rc"] }
thiserror = { workspace = true }
surf-disco = { workspace = true }
time = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
vbs = { workspace = true }
jf-signature.workspace = true
blake3.workspace = true
sha2 = { workspace = true }
url = { workspace = true }
num_enum = "0.7"
parking_lot = "0.12"
Expand All @@ -67,8 +58,6 @@ cdn-marshal = { workspace = true }

[dev-dependencies]
blake3 = { workspace = true }
clap.workspace = true
toml = { workspace = true }

[lints]
workspace = true
Loading

0 comments on commit 078859e

Please sign in to comment.