From beb48dd0bd2370ae713ec1e2ca7be54460312e80 Mon Sep 17 00:00:00 2001 From: Lukas Korba Date: Thu, 4 Jul 2024 08:26:01 +0200 Subject: [PATCH] [#1462] Syncing is broken - The CompactBlockProcessor's state machine got stuck in some cases at the updateChainTip action. [#1462] Syncing is broken - unit test fixed --- CHANGELOG.md | 5 +++++ .../Block/Actions/UpdateChainTipAction.swift | 2 +- Tests/DarksideTests/DarksideSanityCheckTests.swift | 1 + .../UpdateChainTipActionTests.swift | 2 +- Tests/TestUtils/FakeChainBuilder.swift | 3 +++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 729f1e9c..b0fd575b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased +## Fixed + +### [#1462] Syncing is broken +The CompactBlockProcessor's state machine got stuck in some cases at the updateChainTip action. + # 2.1.11 - 2024-07-03 ## Added diff --git a/Sources/ZcashLightClientKit/Block/Actions/UpdateChainTipAction.swift b/Sources/ZcashLightClientKit/Block/Actions/UpdateChainTipAction.swift index 6ad2639e..0398c581 100644 --- a/Sources/ZcashLightClientKit/Block/Actions/UpdateChainTipAction.swift +++ b/Sources/ZcashLightClientKit/Block/Actions/UpdateChainTipAction.swift @@ -44,7 +44,7 @@ extension UpdateChainTipAction: Action { await downloader.stopDownload() try await updateChainTip(context, time: now) await context.update(state: .clearCache) - } else if await context.prevState == .enhance { + } else if await context.prevState == .txResubmission { await context.update(state: .download) } diff --git a/Tests/DarksideTests/DarksideSanityCheckTests.swift b/Tests/DarksideTests/DarksideSanityCheckTests.swift index 21b40cc6..078e1a5d 100644 --- a/Tests/DarksideTests/DarksideSanityCheckTests.swift +++ b/Tests/DarksideTests/DarksideSanityCheckTests.swift @@ -59,6 +59,7 @@ class DarksideSanityCheckTests: ZcashTestCase { let expectedLastBlock = (height: BlockHeight(663200), hash: "2fc7b4682f5ba6ba6f86e170b40f0aa9302e1d3becb2a6ee0db611ff87835e4a") try coordinator.service.addTreeState( + // swiftlint:disable line_length try TreeState(jsonString: """ { diff --git a/Tests/OfflineTests/CompactBlockProcessorActions/UpdateChainTipActionTests.swift b/Tests/OfflineTests/CompactBlockProcessorActions/UpdateChainTipActionTests.swift index ff3aff4e..7c09efad 100644 --- a/Tests/OfflineTests/CompactBlockProcessorActions/UpdateChainTipActionTests.swift +++ b/Tests/OfflineTests/CompactBlockProcessorActions/UpdateChainTipActionTests.swift @@ -91,7 +91,7 @@ final class UpdateChainTipActionTests: ZcashTestCase { do { let context = ActionContextMock.default() - context.prevState = .enhance + context.prevState = .txResubmission context.underlyingLastChainTipUpdateTime = Date().timeIntervalSince1970 context.updateLastChainTipUpdateTimeClosure = { _ in } diff --git a/Tests/TestUtils/FakeChainBuilder.swift b/Tests/TestUtils/FakeChainBuilder.swift index 710653bd..1a1fc5b8 100644 --- a/Tests/TestUtils/FakeChainBuilder.swift +++ b/Tests/TestUtils/FakeChainBuilder.swift @@ -52,6 +52,7 @@ enum FakeChainBuilder { try darksideWallet.addTreeState( + // swiftlint:disable line_length try TreeState(jsonString: """ { @@ -65,6 +66,7 @@ enum FakeChainBuilder { ) try darksideWallet.addTreeState( + // swiftlint:disable line_length try TreeState(jsonString: """ { @@ -78,6 +80,7 @@ enum FakeChainBuilder { ) try darksideWallet.addTreeState( + // swiftlint:disable line_length try TreeState(jsonString: """ {