From 4e90bf222d789daaf606aeda3ba8ea4bf26ea2ca 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) Signed-off-by: Lazar Petrovic --- .../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 5534cdfffd23..a0d49888927f 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 @@ -929,10 +929,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;