Skip to content

Commit

Permalink
Refactors to fit into sequencer TestNetwork (#87)
Browse files Browse the repository at this point in the history
* Refactors for sequencer TestNetwork

* Downgrade async_lock
  • Loading branch information
QuentinI authored Aug 24, 2024
1 parent 0c428de commit 957fd10
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 262 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ async-broadcast = "0.7"
async-compatibility-layer = { version = "1.2.1", default-features = false, features = [
"logging-utils",
] }
async-lock = "3.4"
async-lock = "2.2"
async-std = { version = "1.9.0", features = ["unstable", "attributes"] }
async-trait = "0.1"
clap = { version = "4.5", features = ["derive", "env"] }
committable = "0.2"
derivative = "2.2"
either = "1.13"
futures = "0.3"
hex = "0.4.3"
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.71" }
Expand Down
10 changes: 1 addition & 9 deletions src/builder_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ use async_lock::RwLock;
use core::panic;
use futures::StreamExt;

use std::cmp::PartialEq;
use std::collections::{HashMap, HashSet};
use std::fmt::Debug;
use std::sync::Arc;
use std::time::Instant;
use std::{cmp::PartialEq, num::NonZeroUsize};
use std::{collections::hash_map::Entry, time::Duration};

pub type TxTimeStamp = u128;
Expand All @@ -51,7 +51,6 @@ pub struct DecideMessage<TYPES: NodeType> {
pub struct DaProposalMessage<TYPES: NodeType> {
pub view_number: TYPES::Time,
pub txn_commitments: Vec<Commitment<TYPES::Transaction>>,
pub num_nodes: usize,
pub sender: <TYPES as NodeType>::SignatureKey,
pub builder_commitment: BuilderCommitment,
}
Expand Down Expand Up @@ -156,9 +155,6 @@ pub struct BuilderState<TYPES: NodeType> {
/// global state handle, defined in the service.rs
pub global_state: Arc<RwLock<GlobalState<TYPES>>>,

/// total nodes required for the VID computation as part of block header input response
pub num_nodes: NonZeroUsize,

/// locally spawned builder Commitements
pub builder_commitments: HashSet<(BuilderStateId<TYPES>, BuilderCommitment)>,

Expand Down Expand Up @@ -375,7 +371,6 @@ impl<TYPES: NodeType> BuilderState<TYPES> {
quorum_proposal: Arc<Proposal<TYPES, QuorumProposal<TYPES>>>,
req_sender: BroadcastSender<MessageType<TYPES>>,
) {
self.num_nodes = NonZeroUsize::new(da_proposal_info.num_nodes).unwrap_or(self.num_nodes);
self.built_from_proposed_block.view_number = quorum_proposal.data.view_number;
self.built_from_proposed_block.vid_commitment =
quorum_proposal.data.block_header.payload_commitment();
Expand Down Expand Up @@ -659,7 +654,6 @@ impl<TYPES: NodeType> BuilderState<TYPES> {
req_receiver: BroadcastReceiver<MessageType<TYPES>>,
tx_queue: Vec<Arc<ReceivedTransaction<TYPES>>>,
global_state: Arc<RwLock<GlobalState<TYPES>>>,
num_nodes: NonZeroUsize,
maximize_txn_capture_timeout: Duration,
base_fee: u64,
instance_state: Arc<TYPES::InstanceState>,
Expand All @@ -668,7 +662,6 @@ impl<TYPES: NodeType> BuilderState<TYPES> {
) -> Self {
let txns_in_queue: HashSet<_> = tx_queue.iter().map(|tx| tx.commit).collect();
BuilderState {
num_nodes,
txns_in_queue,
built_from_proposed_block,
req_receiver,
Expand Down Expand Up @@ -706,7 +699,6 @@ impl<TYPES: NodeType> BuilderState<TYPES> {
tx_queue: self.tx_queue.clone(),
global_state: self.global_state.clone(),
builder_commitments: self.builder_commitments.clone(),
num_nodes: self.num_nodes,
maximize_txn_capture_timeout: self.maximize_txn_capture_timeout,
base_fee: self.base_fee,
instance_state: self.instance_state.clone(),
Expand Down
Loading

0 comments on commit 957fd10

Please sign in to comment.