Skip to content

Commit

Permalink
carry epoch number through PackedBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
ss-es committed Dec 6, 2024
1 parent 2fed4ef commit 3ef6a5b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
3 changes: 2 additions & 1 deletion crates/task-impls/src/da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> DaTaskState<TYP
encoded_transactions,
metadata,
view_number,
epoch_number,
..
} = packed_bundle;
let view_number = *view_number;
Expand All @@ -322,7 +323,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> DaTaskState<TYP
metadata: metadata.clone(),
// Upon entering a new view we want to send a DA Proposal for the next view -> Is it always the case that this is cur_view + 1?
view_number,
epoch_number: self.cur_epoch,
epoch_number: *epoch_number,
};

let message = Proposal {
Expand Down
22 changes: 16 additions & 6 deletions crates/task-impls/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
&mut self,
event_stream: &Sender<Arc<HotShotEvent<TYPES>>>,
block_view: TYPES::View,
block_epoch: TYPES::Epoch,
) -> Option<HotShotTaskCompleted> {
let version = match self.upgrade_lock.version(block_view).await {
Ok(v) => v,
Expand All @@ -137,10 +138,10 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
};

if version < V::Marketplace::VERSION {
self.handle_view_change_legacy(event_stream, block_view)
self.handle_view_change_legacy(event_stream, block_view, block_epoch)
.await
} else {
self.handle_view_change_marketplace(event_stream, block_view)
self.handle_view_change_marketplace(event_stream, block_view, block_epoch)
.await
}
}
Expand All @@ -151,6 +152,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
&mut self,
event_stream: &Sender<Arc<HotShotEvent<TYPES>>>,
block_view: TYPES::View,
block_epoch: TYPES::Epoch,
) -> Option<HotShotTaskCompleted> {
let version = match self.upgrade_lock.version(block_view).await {
Ok(v) => v,
Expand Down Expand Up @@ -188,6 +190,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
block_payload.encode(),
metadata,
block_view,
block_epoch,
vec1::vec1![fee],
precompute_data,
None,
Expand Down Expand Up @@ -231,6 +234,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
vec![].into(),
metadata,
block_view,
block_epoch,
vec1::vec1![null_fee],
Some(precompute_data),
None,
Expand All @@ -251,6 +255,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
async fn produce_block_marketplace(
&mut self,
block_view: TYPES::View,
block_epoch: TYPES::Epoch,
task_start_time: Instant,
) -> Result<PackedBundle<TYPES>> {
ensure!(
Expand Down Expand Up @@ -343,6 +348,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
block_payload.encode(),
metadata,
block_view,
block_epoch,
sequencing_fees,
None,
Some(auction_result),
Expand All @@ -353,6 +359,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
pub fn null_block(
&self,
block_view: TYPES::View,
block_epoch: TYPES::Epoch,
version: Version,
) -> Option<PackedBundle<TYPES>> {
let membership_total_nodes = self.membership.total_nodes(self.cur_epoch);
Expand All @@ -374,6 +381,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
vec![].into(),
metadata,
block_view,
block_epoch,
vec1::vec1![null_fee],
Some(precompute_data),
Some(TYPES::AuctionResult::default()),
Expand All @@ -386,6 +394,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
&mut self,
event_stream: &Sender<Arc<HotShotEvent<TYPES>>>,
block_view: TYPES::View,
block_epoch: TYPES::Epoch,
) -> Option<HotShotTaskCompleted> {
let task_start_time = Instant::now();

Expand All @@ -398,7 +407,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
};

let packed_bundle = match self
.produce_block_marketplace(block_view, task_start_time)
.produce_block_marketplace(block_view, block_epoch, task_start_time)
.await
{
Ok(b) => b,
Expand All @@ -409,7 +418,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
e
);

let null_block = self.null_block(block_view, version)?;
let null_block = self.null_block(block_view, block_epoch, version)?;

// Increment the metric for number of empty blocks proposed
self.consensus
Expand Down Expand Up @@ -438,12 +447,13 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
&mut self,
event_stream: &Sender<Arc<HotShotEvent<TYPES>>>,
block_view: TYPES::View,
block_epoch: TYPES::Epoch,
) -> Option<HotShotTaskCompleted> {
if self.consensus.read().await.is_high_qc_forming_eqc() {
tracing::info!("Reached end of epoch. Not getting a new block until we form an eQC.");
None
} else {
self.handle_view_change_marketplace(event_stream, block_view)
self.handle_view_change_marketplace(event_stream, block_view, block_epoch)
.await
}
}
Expand Down Expand Up @@ -481,7 +491,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
);
self.cur_view = view;
if self.membership.leader(view, self.cur_epoch)? == self.public_key {
self.handle_view_change(&event_stream, view).await;
self.handle_view_change(&event_stream, view, *epoch).await;
return Ok(());
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/testing/tests/tests_1/da_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ async fn test_da_task() {
num_transactions: transactions.len() as u64
},
ViewNumber::new(2),
EpochNumber::new(0),
vec1::vec1![null_block::builder_fee::<TestTypes, TestVersions>(
membership.total_nodes(EpochNumber::new(0)),
<TestVersions as Versions>::Base::VERSION,
Expand Down Expand Up @@ -212,6 +213,7 @@ async fn test_da_task_storage_failure() {
num_transactions: transactions.len() as u64
},
ViewNumber::new(2),
EpochNumber::new(0),
vec1::vec1![null_block::builder_fee::<TestTypes, TestVersions>(
membership.total_nodes(EpochNumber::new(0)),
<TestVersions as Versions>::Base::VERSION,
Expand Down
1 change: 1 addition & 0 deletions crates/testing/tests/tests_1/transaction_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async fn test_transaction_task_leader_two_views_in_a_row() {
num_transactions: 0,
},
current_view,
EpochNumber::new(1),
vec1::vec1![
null_block::builder_fee::<TestConsecutiveLeaderTypes, TestVersions>(
handle.hotshot.memberships.total_nodes(EpochNumber::new(0)),
Expand Down
1 change: 1 addition & 0 deletions crates/testing/tests/tests_1/vid_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ async fn test_vid_task() {
num_transactions: transactions.len() as u64
},
ViewNumber::new(2),
EpochNumber::new(0),
vec1::vec1![null_block::builder_fee::<TestTypes, TestVersions>(
membership.total_nodes(EpochNumber::new(0)),
<TestVersions as Versions>::Base::VERSION,
Expand Down
5 changes: 5 additions & 0 deletions crates/types/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,9 @@ pub struct PackedBundle<TYPES: NodeType> {
/// The view number that this block is associated with.
pub view_number: TYPES::View,

/// The view number that this block is associated with.
pub epoch_number: TYPES::Epoch,

/// The sequencing fee for submitting bundles.
pub sequencing_fees: Vec1<BuilderFee<TYPES>>,

Expand All @@ -1283,6 +1286,7 @@ impl<TYPES: NodeType> PackedBundle<TYPES> {
encoded_transactions: Arc<[u8]>,
metadata: <TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata,
view_number: TYPES::View,
epoch_number: TYPES::Epoch,
sequencing_fees: Vec1<BuilderFee<TYPES>>,
vid_precompute: Option<VidPrecomputeData>,
auction_result: Option<TYPES::AuctionResult>,
Expand All @@ -1291,6 +1295,7 @@ impl<TYPES: NodeType> PackedBundle<TYPES> {
encoded_transactions,
metadata,
view_number,
epoch_number,
sequencing_fees,
vid_precompute,
auction_result,
Expand Down

0 comments on commit 3ef6a5b

Please sign in to comment.