Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #108 from EspressoSystems/hg/update_hotshot_0.5.45
Browse files Browse the repository at this point in the history
update_hotshot_0.5.46
  • Loading branch information
jbearer authored Apr 30, 2024
2 parents a972a2c + 8ea88ee commit 2e873a3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 53 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hotshot-builder-core"
version = "0.1.12"
version = "0.1.14"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -15,10 +15,10 @@ async-trait = "0.1"
clap = { version = "4.4", features = ["derive", "env"] }
committable = "0.2"
futures = "0.3"
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.44" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.44" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.14" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.44" }
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.46" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.46" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.16" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.46" }
serde = { version = "1.0", features = ["derive"] }
sha2 = "0.10"
snafu = "0.8"
Expand All @@ -29,4 +29,4 @@ tracing = "0.1"
vbs = "0.1"

[dev-dependencies]
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.44" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.46" }
7 changes: 7 additions & 0 deletions src/builder_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use hotshot_types::{
traits::{
block_contents::precompute_vid_commitment,
node_implementation::{ConsensusTime, NodeType},
states::InstanceState,
},
utils::BuilderCommitment,
vid::{VidCommitment, VidPrecomputeData},
Expand Down Expand Up @@ -181,6 +182,9 @@ pub struct BuilderState<TYPES: NodeType> {

/// constant fee that the builder will offer per byte of data sequenced
pub base_fee: u64,

/// instance state to enfoce max_block_size
pub instance_state: Arc<dyn InstanceState>,
}

/// Trait to hold the helper functions for the builder
Expand Down Expand Up @@ -681,6 +685,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
.get(tx_hash)
.map(|(_ts, tx, _source)| tx.clone())
}),
self.instance_state.clone(),
) {
let builder_hash = payload.builder_commitment(&metadata);
// count the number of txns
Expand Down Expand Up @@ -957,6 +962,7 @@ impl<TYPES: NodeType> BuilderState<TYPES> {
buffer_view_num_count: u64,
maximize_txn_capture_timeout: Duration,
base_fee: u64,
instance_state: Arc<dyn InstanceState>,
) -> Self {
BuilderState {
timestamp_to_tx: BTreeMap::new(),
Expand All @@ -980,6 +986,7 @@ impl<TYPES: NodeType> BuilderState<TYPES> {
buffer_view_num_count,
maximize_txn_capture_timeout,
base_fee,
instance_state,
}
}
}
35 changes: 10 additions & 25 deletions src/service.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use hotshot::{
traits::{
election::static_committee::{GeneralStaticCommittee, StaticElectionConfig},
NodeImplementation,
},
traits::{election::static_committee::GeneralStaticCommittee, NodeImplementation},
types::SystemContextHandle,
};
use hotshot_builder_api::{
Expand Down Expand Up @@ -572,9 +569,7 @@ impl<Types: NodeType> ReadState for ProxyGlobalState<Types> {
/*
Running Non-Permissioned Builder Service
*/
pub async fn run_non_permissioned_standalone_builder_service<
Types: NodeType<ElectionConfigType = StaticElectionConfig>,
>(
pub async fn run_non_permissioned_standalone_builder_service<Types: NodeType>(
// sending a transaction from the hotshot mempool to the builder states
tx_sender: BroadcastSender<MessageType<Types>>,

Expand Down Expand Up @@ -602,24 +597,14 @@ pub async fn run_non_permissioned_standalone_builder_service<
known_node_with_stake,
non_staked_node_count,
} => {
// Create membership. It is similar to init() in sequencer/src/context.rs
let election_config: StaticElectionConfig = GeneralStaticCommittee::<
Types,
<Types as NodeType>::SignatureKey,
>::default_election_config(
known_node_with_stake.len() as u64,
non_staked_node_count as u64,
);

let membership: GeneralStaticCommittee<
Types,
<Types as NodeType>::SignatureKey,
> = GeneralStaticCommittee::<Types,
<Types as NodeType>::SignatureKey>::create_election(
known_node_with_stake.clone(),
election_config,
0,
);
let membership: GeneralStaticCommittee<Types, <Types as NodeType>::SignatureKey> = GeneralStaticCommittee::<
Types,
<Types as NodeType>::SignatureKey,
>::create_election(
known_node_with_stake.clone(),
known_node_with_stake.clone(),
0
);

tracing::info!(
"Startup info: Known nodes with stake: {:?}, Non-staked node count: {:?}",
Expand Down
13 changes: 7 additions & 6 deletions src/testing/basic_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pub use hotshot::traits::election::static_committee::{
GeneralStaticCommittee, StaticElectionConfig,
};
pub use hotshot::traits::election::static_committee::GeneralStaticCommittee;
pub use hotshot_types::{
data::{DAProposal, Leaf, QuorumProposal, ViewNumber},
message::Proposal,
Expand Down Expand Up @@ -77,7 +75,6 @@ mod tests {
type BlockPayload = TestBlockPayload;
type SignatureKey = BLSPubKey;
type Transaction = TestTransaction;
type ElectionConfigType = StaticElectionConfig;
type ValidatedState = TestValidatedState;
type InstanceState = TestInstanceState;
type Membership = GeneralStaticCommittee<TestTypes, Self::SignatureKey>;
Expand Down Expand Up @@ -166,8 +163,11 @@ mod tests {
// Prepare the QC proposal message
// calculate the vid commitment over the encoded_transactions

let (block_payload, metadata) =
<TestBlockPayload as BlockPayload>::from_transactions(vec![tx.clone()]).unwrap();
let (block_payload, metadata) = <TestBlockPayload as BlockPayload>::from_transactions(
vec![tx.clone()],
Arc::new(TestInstanceState {}),
)
.unwrap();

tracing::debug!(
"Encoded transactions: {:?} Num nodes:{}",
Expand Down Expand Up @@ -341,6 +341,7 @@ mod tests {
10, // buffer view count
Duration::from_millis(10), // max time to wait for non-zero txn block
0, // base fee
Arc::new(TestInstanceState {}),
);

//builder_state.event_loop().await;
Expand Down

0 comments on commit 2e873a3

Please sign in to comment.