diff --git a/massa-execution-worker/src/active_history.rs b/massa-execution-worker/src/active_history.rs index 7cf4cd737ab..c632a2405be 100644 --- a/massa-execution-worker/src/active_history.rs +++ b/massa-execution-worker/src/active_history.rs @@ -250,7 +250,7 @@ impl ActiveHistory { return SlotIndexPosition::Past; // too old } let index: usize = match slot.slots_since(first_slot, thread_count) { - Err(_) => return SlotIndexPosition::Future, // overflow + Err(_) => return SlotIndexPosition::Past, // overflow Ok(d) => { match d.try_into() { Ok(d) => d, diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 02d017b5c08..6869082b025 100644 --- a/massa-execution-worker/src/controller.rs +++ b/massa-execution-worker/src/controller.rs @@ -535,7 +535,7 @@ pub struct ExecutionManagerImpl { impl ExecutionManager for ExecutionManagerImpl { /// stops the worker fn stop(&mut self) { - info!("stopping Execution controller..."); + info!("Stopping Execution controller..."); // notify the worker thread to stop { let mut input_wlock = self.input_data.1.lock(); @@ -544,8 +544,10 @@ impl ExecutionManager for ExecutionManagerImpl { } // join the execution thread if let Some(join_handle) = self.thread_handle.take() { - join_handle.join().expect("VM controller thread panicked"); + join_handle + .join() + .expect("Execution controller thread panicked"); } - info!("execution controller stopped"); + info!("Execution controller stopped"); } } diff --git a/massa-execution-worker/src/speculative_async_pool.rs b/massa-execution-worker/src/speculative_async_pool.rs index 3a5c654d7a8..082ed2fb362 100644 --- a/massa-execution-worker/src/speculative_async_pool.rs +++ b/massa-execution-worker/src/speculative_async_pool.rs @@ -340,7 +340,7 @@ impl SpeculativeAsyncPool { /// Check in the ledger changes if a message trigger has been triggered fn is_triggered(filter: &AsyncMessageTrigger, ledger_changes: &LedgerChanges) -> bool { - ledger_changes.has_changes(&filter.address, filter.datastore_key.clone()) + ledger_changes.has_writes(&filter.address, filter.datastore_key.clone()) } #[cfg(test)] diff --git a/massa-execution-worker/src/speculative_executed_denunciations.rs b/massa-execution-worker/src/speculative_executed_denunciations.rs index 8c7466bc844..1c8f9bb2c13 100644 --- a/massa-execution-worker/src/speculative_executed_denunciations.rs +++ b/massa-execution-worker/src/speculative_executed_denunciations.rs @@ -73,10 +73,8 @@ impl SpeculativeExecutedDenunciations { HistorySearchResult::Present(_) => { return true; } - HistorySearchResult::Absent => { - return false; - } HistorySearchResult::NoInfo => {} + HistorySearchResult::Absent => unreachable!(), // fetch_executed_denunciation does not return Absent } // check in the final state diff --git a/massa-execution-worker/src/speculative_executed_ops.rs b/massa-execution-worker/src/speculative_executed_ops.rs index 1c3d1037678..d3d0d81c0e1 100644 --- a/massa-execution-worker/src/speculative_executed_ops.rs +++ b/massa-execution-worker/src/speculative_executed_ops.rs @@ -67,10 +67,8 @@ impl SpeculativeExecutedOps { HistorySearchResult::Present(_) => { return true; } - HistorySearchResult::Absent => { - return false; - } HistorySearchResult::NoInfo => {} + HistorySearchResult::Absent => unreachable!(), // fetch_executed_op does not return Absent } // check in the final state diff --git a/massa-execution-worker/src/worker.rs b/massa-execution-worker/src/worker.rs index 332ac92f25e..5fee6e65eac 100644 --- a/massa-execution-worker/src/worker.rs +++ b/massa-execution-worker/src/worker.rs @@ -260,6 +260,10 @@ pub fn start_execution_worker( massa_metrics: MassaMetrics, #[cfg(feature = "dump-block")] block_storage_backend: Arc>, ) -> (Box, Box) { + if config.hd_cache_size < config.snip_amount { + panic!("In config.toml, hd_cache_size must be greater than snip_amount"); + } + // create an execution state let execution_state = Arc::new(RwLock::new(ExecutionState::new( config.clone(), diff --git a/massa-ledger-exports/src/ledger_changes.rs b/massa-ledger-exports/src/ledger_changes.rs index 02551f0b096..5c4e1eb5839 100644 --- a/massa-ledger-exports/src/ledger_changes.rs +++ b/massa-ledger-exports/src/ledger_changes.rs @@ -835,8 +835,13 @@ impl LedgerChanges { } } - /// Tries to return whether there is a change on a given address in the ledger changes - /// and optionally if a datastore key modification also exists in the address's datastore. + /// Tries to return whether the ledger changes contain a write for the given address + /// and optionally if a datastore key write also exists in the address's datastore. + /// Notes: + /// - A ledger entry could be written to without any changes on the values associated, + /// for example if the value was changed multiple times in the same slot. + /// - This code assumes Delete cannot be shadowed by Set operations in the same slot, which may not be the case + /// when / if we allow full entry Delete given the current LedgerChanges::Delete handling. In that case, a rework may be necessary. /// /// # Arguments /// * `addr`: target address @@ -844,7 +849,7 @@ impl LedgerChanges { /// /// # Returns /// * true if the address and, optionally the datastore key, exists in the ledger changes - pub fn has_changes(&self, addr: &Address, key: Option>) -> bool { + pub fn has_writes(&self, addr: &Address, key: Option>) -> bool { // Get the current changes being applied to the ledger entry associated to that address match self.0.get(addr) { // This ledger entry is being replaced by a new one: