From b6b8fa68f9374f40a9746e99698bc5916ad02ec9 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Thu, 1 Aug 2024 14:27:56 +0200 Subject: [PATCH 1/6] Fix slot index position status (#4736) * Fix SlotIndexPosition from Future to Past in case slots_since returns an error * Update ci.yml --- massa-execution-worker/src/active_history.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From 8c32b899041c18a36df12632c57001f787f5a431 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Fri, 2 Aug 2024 16:18:37 +0200 Subject: [PATCH 2/6] Validate that hd_cache_size >= snip_amount (#4732) --- massa-execution-worker/src/worker.rs | 4 ++++ 1 file changed, 4 insertions(+) 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(), From 2d94edd8d22ccc30386a9a1bfda729d36f1d6a83 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Fri, 2 Aug 2024 16:23:48 +0200 Subject: [PATCH 3/6] Improve handling of HistorySearchResult for fetched executed_ops/denunciations (#4735) * Improve handling of HistorySearchResult * Fix CI --- .../src/speculative_executed_denunciations.rs | 4 +--- massa-execution-worker/src/speculative_executed_ops.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) 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 From d98df3bf0ac0e3615631570db0286ae86eab503b Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Mon, 12 Aug 2024 15:13:49 +0200 Subject: [PATCH 4/6] Update ASC trigger comment (#4740) * Update ASC trigger comment * Add comment for ledger entry deletions * fmt --- massa-execution-worker/src/speculative_async_pool.rs | 2 +- massa-ledger-exports/src/ledger_changes.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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-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: From 8612838a42bcb5c1790135210f4bd2e8081216a7 Mon Sep 17 00:00:00 2001 From: sydhds Date: Thu, 19 Sep 2024 11:44:43 +0200 Subject: [PATCH 5/6] Fix join error message (was inconsistent with: VM controller thread) --- massa-execution-worker/src/controller.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 02d017b5c08..233ba75902a 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,8 @@ 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"); } } From f29a0b33826363e3ffffa940715108b76a766dc5 Mon Sep 17 00:00:00 2001 From: sydhds Date: Fri, 20 Sep 2024 10:47:45 +0200 Subject: [PATCH 6/6] Cargo fmt pass --- massa-execution-worker/src/controller.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 233ba75902a..6869082b025 100644 --- a/massa-execution-worker/src/controller.rs +++ b/massa-execution-worker/src/controller.rs @@ -544,7 +544,9 @@ impl ExecutionManager for ExecutionManagerImpl { } // join the execution thread if let Some(join_handle) = self.thread_handle.take() { - join_handle.join().expect("Execution controller thread panicked"); + join_handle + .join() + .expect("Execution controller thread panicked"); } info!("Execution controller stopped"); }