From caef95b129b65981437ca33474e9e2e51d5430dc Mon Sep 17 00:00:00 2001 From: ABresting Date: Thu, 12 Mar 2026 00:51:05 +0530 Subject: [PATCH] fix: remove VLC double-increment on event receive VLC::merge() calls VLCSnapshot::receive() which already performs merge + increment. The extra vlc.tick() in add_event() and receive_event_from_network() caused the local vector clock entry and logical_time to advance by 2 per receive instead of 1. Fixes #22 --- consensus/src/engine.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consensus/src/engine.rs b/consensus/src/engine.rs index a60c4c4..60d4237 100644 --- a/consensus/src/engine.rs +++ b/consensus/src/engine.rs @@ -288,10 +288,10 @@ impl ConsensusEngine { /// ensuring proper depth calculation and three-layer storage management. pub async fn add_event(&self, event: Event) -> SetuResult { // Update local VLC by merging with the event's VLC + // merge() calls VLCSnapshot::receive() which already does merge + increment { let mut vlc = self.vlc.write().await; vlc.merge(&event.vlc_snapshot); - vlc.tick(); } // Add event through DagManager with retry (handles TOCTOU race with GC) @@ -352,10 +352,10 @@ impl ConsensusEngine { /// Unlike `add_event`, this does not broadcast the event again to avoid message loops. pub async fn receive_event_from_network(&self, event: Event) -> SetuResult { // Update local VLC by merging with the event's VLC + // merge() calls VLCSnapshot::receive() which already does merge + increment { let mut vlc = self.vlc.write().await; vlc.merge(&event.vlc_snapshot); - vlc.tick(); } // Add event through DagManager with retry (handles TOCTOU race with GC)