Skip to content

Commit

Permalink
Add feature slot-replayer
Browse files Browse the repository at this point in the history
if feature is enabled:
- don't do speculative execution
- don't take time_cursor() into account while initializing block_sequencer

Signed-off-by: Jean-François <[email protected]>
  • Loading branch information
bilboquet committed May 27, 2024
1 parent 206dc3c commit 945a774
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion massa-execution-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ dump-block = [
]
db_storage_backend = []
file_storage_backend = []

execution-info = ["execution-trace"]
slot-replayer = []

[dependencies]
anyhow = { workspace = true }
Expand Down
35 changes: 22 additions & 13 deletions massa-execution-worker/src/slot_sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ impl SlotSequencer {
// This is the max between the latest CSS-final slot, the latest blockclique slot,
// and the latest slot to be executed in time.
let max_slot = std::cmp::max(
std::cmp::max(
*self
.latest_consensus_final_slots
.iter()
.max()
.expect("latest_consensus_final_slots is empty"),
initial_blockclique
.keys()
.max()
.copied()
.unwrap_or_else(|| Slot::new(self.config.last_start_period, 0)),
),
self.get_time_cursor(),
*self
.latest_consensus_final_slots
.iter()
.max()
.expect("latest_consensus_final_slots is empty"),
initial_blockclique
.keys()
.max()
.copied()
.unwrap_or_else(|| Slot::new(self.config.last_start_period, 0)),
);

#[cfg(not(feature = "slot-replayer"))]
let max_slot = std::cmp::max(max_slot, self.get_time_cursor());

// Iterate from the starting slot to the `max_slot` to build the slot sequence.
while slot <= max_slot {
// If the slot is rearlier than (or equal to) the latest CSS-final slot in that thread => mark the slot as CSS-final
Expand Down Expand Up @@ -209,9 +209,16 @@ impl SlotSequencer {
pub fn update(
&mut self,
mut new_consensus_final_blocks: HashMap<Slot, BlockId>,
#[cfg_attr(feature = "slot-replayer", allow(unused_assignments))]
mut new_blockclique: Option<HashMap<Slot, BlockId>>,
mut new_blocks_metadata: PreHashMap<BlockId, ExecutionBlockMetadata>,
) {
// as a precaution, if we don't want to process speculative slots, clear the speculative feed just in case
#[cfg(feature = "slot-replayer")]
{
new_blockclique = None;
}

// If the slot sequence is empty, initialize it by calling `Self::init` and quit.
// This happens on the first call to `Self::update` (see the doc of `Self::update`).
if self.sequence.is_empty() {
Expand Down Expand Up @@ -589,6 +596,7 @@ impl SlotSequencer {
}

// Check if the next candidate slot is available for execution.
#[cfg(not(feature = "slot-replayer"))]
{
// Get the slot just after the last executed candidate slot.
let next_candidate_slot = self
Expand Down Expand Up @@ -706,6 +714,7 @@ impl SlotSequencer {
// Here we know that there are no SCE-final slots to execute.

// Low priority: execute the next candidate slot that is available for execution, if any.
#[cfg(not(feature = "slot-replayer"))]
{
// Get the slot just after the latest executed speculative slot.
let slot = self
Expand Down

0 comments on commit 945a774

Please sign in to comment.