Skip to content

Commit

Permalink
Hotshot/rc 0.5.60 (#1653)
Browse files Browse the repository at this point in the history
Closes #<ISSUE_NUMBER>
<!-- These comments should help create a useful PR message, please
delete any remaining comments before opening the PR. -->
<!-- If there is no issue number make sure to describe clearly *why*
this PR is necessary. -->
<!-- Mention open questions, remaining TODOs, if any -->

### This PR:
<!-- Describe what this PR adds to this repo and why -->
<!-- E.g. -->
<!-- * Implements feature 1 -->
<!-- * Fixes bug 3 -->

### This PR does not:
<!-- Describe what is out of scope for this PR, if applicable. Leave
this section blank if it's not applicable -->
<!-- This section helps avoid the reviewer having to needlessly point
out missing parts -->
<!-- * Implement feature 3 because that feature is blocked by Issue 4
-->
<!-- * Implement xyz because that is tracked in issue #123. -->
<!-- * Address xzy for which I opened issue #456 -->

### Key places to review:
<!-- Describe key places for reviewers to pay close attention to -->
<!-- * file.rs, `add_integers` function -->
<!-- Or directly comment on those files/lines to make it easier for the
reviewers -->

<!-- ### How to test this PR:  -->
<!-- Optional, uncomment the above line if this is relevant to your PR
-->
<!-- If your PR is fully tested through CI there is no need to add this
section -->
<!-- * E.g. `just test` -->

<!-- ### Things tested -->
<!-- Anything that was manually tested (that is not tested in CI). -->
<!-- E.g. building/running of docker containers. Changes to docker demo,
... -->
<!-- Especially mention anything untested, with reasoning and link an
issue to resolve this. -->

<!-- Complete the following items before creating this PR -->
<!-- [ ] Issue linked or PR description mentions why this change is
necessary. -->
<!-- [ ] PR description is clear enough for reviewers. -->
<!-- [ ] Documentation for changes (additions) has been updated (added).
-->
<!-- [ ] If this is a draft it is marked as "draft".  -->

<!-- To make changes to this template edit
https://github.com/EspressoSystems/.github/blob/main/PULL_REQUEST_TEMPLATE.md
-->
  • Loading branch information
jparr721 authored Jul 2, 2024
2 parents 0c57f56 + 948c09a commit 7b4866f
Show file tree
Hide file tree
Showing 17 changed files with 391 additions and 346 deletions.
338 changes: 178 additions & 160 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@ dotenvy = "0.15"
ethers = { version = "2.0", features = ["solc"] }
futures = "0.3"

hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.59" }
hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.60" }
# Hotshot imports
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.59" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "rc-0.1.32" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "rc-0.1.29" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.59" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "rc-0.1.41" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.59" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.60" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "rc-0.1.31-patch-1" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "rc-0.1.31" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.60" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "rc-0.1.43" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.60" }
hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.59" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.59" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.59" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.60" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.60" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.60" }
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.60" }

# Push CDN imports
cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", features = [
Expand Down
1 change: 1 addition & 0 deletions builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ hotshot = { workspace = true }
hotshot-builder-api = { workspace = true }
hotshot-builder-core = { workspace = true }
hotshot-events-service = { workspace = true }
hotshot-example-types = { workspace = true }
hotshot-orchestrator = { workspace = true }
hotshot-stake-table = { workspace = true }
hotshot-state-prover = { path = "../hotshot-state-prover" }
Expand Down
47 changes: 25 additions & 22 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ use futures::{
use hotshot::{
traits::election::static_committee::GeneralStaticCommittee,
types::{SignatureKey, SystemContextHandle},
HotShotInitializer, Memberships, Networks, SystemContext,
HotShotInitializer, Memberships, SystemContext,
};
use hotshot_orchestrator::{
client::{OrchestratorClient, ValidatorArgs},
config::NetworkConfig,
};
use hotshot_types::{
consensus::ConsensusMetricsValue,
constants::Base,
event::Event,
light_client::StateKeyPair,
signature_key::{BLSPrivKey, BLSPubKey},
Expand All @@ -37,7 +36,10 @@ use async_compatibility_layer::art::{async_sleep, async_spawn};
use hotshot_builder_api::builder::{
BuildError, Error as BuilderApiError, Options as HotshotBuilderApiOptions,
};
use hotshot_builder_core::service::{GlobalState, ProxyGlobalState};
use hotshot_builder_core::{
service::{GlobalState, ProxyGlobalState},
testing::basic_test::NodeType,
};
use jf_merkle_tree::{namespaced_merkle_tree::NamespacedMerkleTreeScheme, MerkleTreeScheme};
use jf_signature::bls_over_bn254::VerKey;
use sequencer::catchup::mock::MockStateCatchup;
Expand Down Expand Up @@ -65,18 +67,20 @@ pub mod permissioned;
// It runs the api service for the builder
pub fn run_builder_api_service(url: Url, source: ProxyGlobalState<SeqTypes>) {
// it is to serve hotshot
let builder_api =
hotshot_builder_api::builder::define_api::<ProxyGlobalState<SeqTypes>, SeqTypes, Base>(
&HotshotBuilderApiOptions::default(),
)
.expect("Failed to construct the builder APIs");
let builder_api = hotshot_builder_api::builder::define_api::<
ProxyGlobalState<SeqTypes>,
SeqTypes,
<SeqTypes as NodeType>::Base,
>(&HotshotBuilderApiOptions::default())
.expect("Failed to construct the builder APIs");

// it enables external clients to submit txn to the builder's private mempool
let private_mempool_api =
hotshot_builder_api::builder::submit_api::<ProxyGlobalState<SeqTypes>, SeqTypes, Base>(
&HotshotBuilderApiOptions::default(),
)
.expect("Failed to construct the builder API for private mempool txns");
let private_mempool_api = hotshot_builder_api::builder::submit_api::<
ProxyGlobalState<SeqTypes>,
SeqTypes,
<SeqTypes as NodeType>::Base,
>(&HotshotBuilderApiOptions::default())
.expect("Failed to construct the builder API for private mempool txns");

let mut app: App<ProxyGlobalState<SeqTypes>, BuilderApiError> = App::with_state(source);

Expand All @@ -86,7 +90,7 @@ pub fn run_builder_api_service(url: Url, source: ProxyGlobalState<SeqTypes>) {
app.register_module("txn_submit", private_mempool_api)
.expect("Failed to register the private mempool API");

async_spawn(app.serve(url, Base::instance()));
async_spawn(app.serve(url, <SeqTypes as NodeType>::Base::instance()));
}

#[cfg(test)]
Expand Down Expand Up @@ -225,6 +229,10 @@ pub mod testing {
stop_proposing_view: 0,
start_voting_view: 0,
stop_voting_view: 0,
start_proposing_time: 0,
start_voting_time: 0,
stop_proposing_time: 0,
stop_voting_time: 0,
};

Self {
Expand Down Expand Up @@ -380,11 +388,6 @@ pub mod testing {
&self.master_map,
None,
));
let networks = Networks {
da_network: network.clone(),
quorum_network: network,
_pd: Default::default(),
};

let node_state = NodeState::new(
i as u64,
Expand All @@ -399,7 +402,7 @@ pub mod testing {
config,
Some(self.non_staking_nodes_stake_entries.clone()),
node_state,
networks,
network,
metrics,
i as u64,
None,
Expand Down Expand Up @@ -434,7 +437,7 @@ pub mod testing {
let hotshot_events_api = hotshot_events_service::events::define_api::<
Arc<RwLock<EventsStreamer<SeqTypes>>>,
SeqTypes,
Base,
<SeqTypes as NodeType>::Base,
>(&EventStreamingApiOptions::default())
.expect("Failed to define hotshot eventsAPI");

Expand All @@ -443,7 +446,7 @@ pub mod testing {
app.register_module("hotshot-events", hotshot_events_api)
.expect("Failed to register hotshot events API");

async_spawn(app.serve(url, Base::instance()));
async_spawn(app.serve(url, <SeqTypes as NodeType>::Base::instance()));
}
// enable hotshot event streaming
pub fn enable_hotshot_node_event_streaming<P: SequencerPersistence>(
Expand Down
8 changes: 4 additions & 4 deletions builder/src/non_permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ mod test {
events::{Error as EventStreamApiError, Options as EventStreamingApiOptions},
events_source::{BuilderEvent, EventConsumer, EventsStreamer},
};
use hotshot_types::constants::Base;
use hotshot_types::traits::{
block_contents::{BlockPayload, GENESIS_VID_NUM_STORAGE_NODES},
node_implementation::NodeType,
Expand Down Expand Up @@ -315,9 +314,10 @@ mod test {
let builder_pub_key = builder_config.fee_account;

// Start a builder api client
let builder_client = Client::<hotshot_builder_api::builder::Error, Base>::new(
hotshot_builder_api_url.clone(),
);
let builder_client = Client::<
hotshot_builder_api::builder::Error,
<SeqTypes as NodeType>::Base,
>::new(hotshot_builder_api_url.clone());
assert!(builder_client.connect(Some(Duration::from_secs(60))).await);

let seed = [207_u8; 32];
Expand Down
47 changes: 20 additions & 27 deletions builder/src/permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use hotshot::{
},
},
types::{SignatureKey, SystemContextHandle},
HotShotInitializer, Memberships, Networks, SystemContext,
HotShotInitializer, Memberships, SystemContext,
};
use hotshot_example_types::auction_results_provider_types::TestAuctionResultsProvider;
use hotshot_orchestrator::{
client::{OrchestratorClient, ValidatorArgs},
config::NetworkConfig,
Expand All @@ -28,7 +29,7 @@ use hotshot_types::{
event::Event,
light_client::StateKeyPair,
signature_key::{BLSPrivKey, BLSPubKey},
traits::{election::Membership, metrics::Metrics, EncodeBytes},
traits::{election::Membership, metrics::Metrics, network::ConnectedNetwork, EncodeBytes},
utils::BuilderCommitment,
HotShotConfig, PeerConfig, ValidatorConfig,
};
Expand Down Expand Up @@ -105,7 +106,7 @@ use std::{num::NonZeroUsize, time::Duration};
use surf_disco::Client;

pub struct BuilderContext<
N: network::Type,
N: ConnectedNetwork<PubKey>,
P: SequencerPersistence,
Ver: StaticVersionType + 'static,
> {
Expand Down Expand Up @@ -150,6 +151,7 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
let validator_args = ValidatorArgs {
url: network_params.orchestrator_url,
advertise_address: Some(network_params.libp2p_advertise_address),
builder_address: None,
network_config_file: None,
};
let orchestrator_client = OrchestratorClient::new(validator_args);
Expand Down Expand Up @@ -233,24 +235,14 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static

// Combine the communication channels
#[cfg(feature = "libp2p")]
let (da_network, quorum_network) = {
let network = Arc::new(CombinedNetworks::new(
cdn_network,
p2p_network,
Duration::from_secs(1),
));
(Arc::clone(&network), network)
};
let network = Arc::new(CombinedNetworks::new(
cdn_network,
p2p_network,
Duration::from_secs(1),
));

#[cfg(not(feature = "libp2p"))]
let (da_network, quorum_network) = { (Arc::from(cdn_network.clone()), Arc::from(cdn_network)) };

// Convert to the sequencer-compatible type
let networks = Networks {
da_network,
quorum_network,
_pd: Default::default(),
};
let network = Arc::from(cdn_network.clone());

let mut genesis_state = ValidatedState {
chain_config: genesis.chain_config.into(),
Expand Down Expand Up @@ -292,7 +284,7 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
config.config,
None,
instance_state.clone(),
networks,
network,
metrics,
node_index,
Some(network_params.state_relay_server_url),
Expand Down Expand Up @@ -324,7 +316,7 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static

#[allow(clippy::too_many_arguments)]
pub async fn init_hotshot<
N: network::Type,
N: ConnectedNetwork<PubKey>,
P: SequencerPersistence,
Ver: StaticVersionType + 'static,
>(
Expand All @@ -333,7 +325,7 @@ pub async fn init_hotshot<
Vec<PeerConfig<hotshot_state_prover::QCVerKey>>,
>,
instance_state: NodeState,
networks: Networks<SeqTypes, Node<N, P>>,
networks: Arc<N>,
metrics: &dyn Metrics,
node_id: u64,
state_relay_server: Option<Url>,
Expand Down Expand Up @@ -381,6 +373,7 @@ pub async fn init_hotshot<
.unwrap(),
ConsensusMetricsValue::new(metrics),
da_storage,
TestAuctionResultsProvider::default(),
)
.await
.unwrap()
Expand All @@ -396,7 +389,7 @@ pub async fn init_hotshot<
(hotshot_handle, state_signer)
}

impl<N: network::Type, P: SequencerPersistence, Ver: StaticVersionType + 'static>
impl<N: ConnectedNetwork<PubKey>, P: SequencerPersistence, Ver: StaticVersionType + 'static>
BuilderContext<N, P, Ver>
{
/// Constructor
Expand Down Expand Up @@ -566,7 +559,6 @@ mod test {
events::{Error as EventStreamApiError, Options as EventStreamingApiOptions},
events_source::{BuilderEvent, EventConsumer, EventsStreamer},
};
use hotshot_types::constants::Base;
use hotshot_types::{
signature_key::BLSPubKey,
traits::{
Expand Down Expand Up @@ -621,9 +613,10 @@ mod test {
let builder_pub_key = builder_config.fee_account;

// Start a builder api client
let builder_client = Client::<hotshot_builder_api::builder::Error, Base>::new(
hotshot_builder_api_url.clone(),
);
let builder_client = Client::<
hotshot_builder_api::builder::Error,
<SeqTypes as NodeType>::Base,
>::new(hotshot_builder_api_url.clone());
assert!(builder_client.connect(Some(Duration::from_secs(60))).await);

let seed = [207_u8; 32];
Expand Down
1 change: 1 addition & 0 deletions sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ paste = "1.0"
hotshot = { workspace = true }
hotshot-contract-adapter = { workspace = true }
hotshot-events-service = { workspace = true }
hotshot-example-types = { workspace = true }
hotshot-orchestrator = { workspace = true }
hotshot-query-service = { workspace = true }
hotshot-stake-table = { workspace = true }
Expand Down
Loading

0 comments on commit 7b4866f

Please sign in to comment.