From e785d21e03bfcf28fb584ca17f381970e41b71c5 Mon Sep 17 00:00:00 2001 From: Lazar Petrovic Date: Tue, 13 Feb 2024 14:35:57 +0100 Subject: [PATCH] fix: state sent to be saved twice (#11488) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lazar Petrovic Signed-off-by: Timo Brandstätter --- .../src/main/java/com/swirlds/platform/SwirldsPlatform.java | 6 ++++-- .../platform/state/signed/SignedStateFileManager.java | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java index d9f06cf30d37..06f4d2c1a600 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java @@ -910,10 +910,12 @@ private void loadReconnectState(final SignedState signedState) { // this guarantees that the platform status will be RECONNECT_COMPLETE before the state is saved platformStatusManager.submitStatusAction(new ReconnectCompleteAction(signedState.getRound())); latestImmutableState.setState(signedState.reserve("set latest immutable to reconnect state")); - stateManagementComponent.stateToLoad(signedState, SourceOfSignedState.RECONNECT); savedStateController.reconnectStateReceived( signedState.reserve("savedStateController.reconnectStateReceived")); - platformWiring.getSaveStateToDiskInput().put(signedState.reserve("save reconnect state to disk")); + // this will send the state to the signature collector which will send it to be written to disk. + // in the future, we might not send it to the collector because it already has all the signatures + // if this is the case, we must make sure to send it to the writer directly + stateManagementComponent.stateToLoad(signedState, SourceOfSignedState.RECONNECT); loadStateIntoConsensus(signedState); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileManager.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileManager.java index cd5c3f6043e4..b23fd33ea418 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileManager.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileManager.java @@ -18,7 +18,6 @@ import static com.swirlds.common.io.utility.FileUtils.deleteDirectoryAndLog; import static com.swirlds.logging.legacy.LogMarker.EXCEPTION; -import static com.swirlds.logging.legacy.LogMarker.STATE_TO_DISK; import static com.swirlds.platform.state.signed.StateToDiskReason.UNKNOWN; import com.swirlds.base.time.Time; @@ -126,7 +125,7 @@ public SignedStateFileManager( final SignedState signedState = reservedSignedState.get(); if (signedState.hasStateBeenSavedToDisk()) { logger.info( - STATE_TO_DISK.getMarker(), + EXCEPTION.getMarker(), "Not saving signed state for round {} to disk because it has already been saved.", signedState.getRound()); return null;