Skip to content

Commit 0865984

Browse files
Disable UpdateHistory for SV and Splitwell apps (#2675)
* Disable UpdateHistory for SV and Splitwell apps * Make scanConfig mandatory in SV app (#2686) --------- Signed-off-by: Oriol Muñoz <[email protected]>
1 parent 293027e commit 0865984

File tree

69 files changed

+566
-504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+566
-504
lines changed

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/plugins/UpdateHistorySanityCheckPlugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class UpdateHistorySanityCheckPlugin(
270270
interval = Span(100, Millis),
271271
)
272272
eventually {
273-
scan.automation.store.updateHistory
273+
scan.automation.updateHistory
274274
.getBackfillingState()
275275
.futureValue should be(BackfillingState.Complete)
276276
}(

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/DecentralizedSynchronizerMigrationIntegrationTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,14 +1002,14 @@ class DecentralizedSynchronizerMigrationIntegrationTest
10021002

10031003
withClueAndLog("Backfilled history includes ACS import") {
10041004
eventually() {
1005-
sv1ScanLocalBackend.appState.store.updateHistory.sourceHistory
1005+
sv1ScanLocalBackend.appState.automation.updateHistory.sourceHistory
10061006
.migrationInfo(1L)
10071007
.futureValue
10081008
.exists(_.complete) should be(true)
10091009
}
10101010

10111011
val backfilledUpdates =
1012-
sv1ScanLocalBackend.appState.store.updateHistory
1012+
sv1ScanLocalBackend.appState.automation.updateHistory
10131013
.getAllUpdates(None, PageLimit.tryCreate(1000))
10141014
.futureValue
10151015
backfilledUpdates.collect {

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanHistoryBackfillingIntegrationTest.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ class ScanHistoryBackfillingIntegrationTest
279279
)(
280280
"History marked as free of corrupt snapshots",
281281
_ => {
282-
sv1ScanBackend.appState.store.updateHistory.corruptAcsSnapshotsDeleted shouldBe true
283-
sv2ScanBackend.appState.store.updateHistory.corruptAcsSnapshotsDeleted shouldBe true
282+
sv1ScanBackend.appState.automation.updateHistory.corruptAcsSnapshotsDeleted shouldBe true
283+
sv2ScanBackend.appState.automation.updateHistory.corruptAcsSnapshotsDeleted shouldBe true
284284
},
285285
)
286286

@@ -307,15 +307,15 @@ class ScanHistoryBackfillingIntegrationTest
307307
)(
308308
"Backfilling is complete only on the founding SV",
309309
_ => {
310-
sv1ScanBackend.appState.store.updateHistory
310+
sv1ScanBackend.appState.automation.updateHistory
311311
.getBackfillingState()
312312
.futureValue should be(BackfillingState.Complete)
313313
// Update history is complete at this point, but the status endpoint only reports
314314
// as complete if the txlog is also backfilled
315315
sv1ScanBackend.getBackfillingStatus().complete shouldBe false
316316
readUpdateHistoryFromScan(sv1ScanBackend) should not be empty
317317

318-
sv2ScanBackend.appState.store.updateHistory
318+
sv2ScanBackend.appState.automation.updateHistory
319319
.getBackfillingState()
320320
.futureValue should be(BackfillingState.InProgress(false, false))
321321
sv2ScanBackend.getBackfillingStatus().complete shouldBe false
@@ -354,12 +354,12 @@ class ScanHistoryBackfillingIntegrationTest
354354
)(
355355
"All backfilling is complete",
356356
_ => {
357-
sv1ScanBackend.appState.store.updateHistory
357+
sv1ScanBackend.appState.automation.updateHistory
358358
.getBackfillingState()
359359
.futureValue should be(BackfillingState.Complete)
360360
// Update history is complete, TxLog is not
361361
sv1ScanBackend.getBackfillingStatus().complete shouldBe false
362-
sv2ScanBackend.appState.store.updateHistory
362+
sv2ScanBackend.appState.automation.updateHistory
363363
.getBackfillingState()
364364
.futureValue should be(BackfillingState.Complete)
365365
// Update history is complete, TxLog is not
@@ -444,7 +444,7 @@ class ScanHistoryBackfillingIntegrationTest
444444
clue("Compare scan history with participant update stream") {
445445
compareHistory(
446446
sv1Backend.participantClient,
447-
sv1ScanBackend.appState.store.updateHistory,
447+
sv1ScanBackend.appState.automation.updateHistory,
448448
ledgerBeginSv1,
449449
)
450450
}
@@ -554,7 +554,7 @@ class ScanHistoryBackfillingIntegrationTest
554554

555555
private def allUpdatesFromScanBackend(scanBackend: ScanAppBackendReference) = {
556556
// Need to use the store directly, as the HTTP endpoint refuses to return data unless it's completely backfilled
557-
scanBackend.appState.store.updateHistory
557+
scanBackend.appState.automation.updateHistory
558558
.getAllUpdates(None, PageLimit.tryCreate(1000))
559559
.futureValue
560560
}

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanTimeBasedIntegrationTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ class ScanTimeBasedIntegrationTest
439439
"Wait for backfilling to complete, as the ACS snapshot trigger is paused until then"
440440
) {
441441
eventually() {
442-
sv1ScanBackend.automation.store.updateHistory
442+
sv1ScanBackend.automation.updateHistory
443443
.getBackfillingState()
444444
.futureValue should be(BackfillingState.Complete)
445445
advanceTime(sv1ScanBackend.config.automation.pollingInterval.asJava)

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanTotalSupplyBigQueryIntegrationTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class ScanTotalSupplyBigQueryIntegrationTest
325325
case db: DbStorage => db
326326
case s => fail(s"non-DB storage configured, unsupported for BigQuery: ${s.getClass}")
327327
}
328-
val sourceHistoryId = sv1ScanBackend.appState.store.updateHistory.historyId
328+
val sourceHistoryId = sv1ScanBackend.appState.automation.updateHistory.historyId
329329

330330
copyTableToBigQuery(
331331
"update_history_creates",

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/UpdateHistoryIntegrationTest.scala

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class UpdateHistoryIntegrationTest
154154
eventually() {
155155
compareHistory(
156156
sv1Backend.participantClient,
157-
sv1ScanBackend.appState.store.updateHistory,
157+
sv1ScanBackend.appState.automation.updateHistory,
158158
ledgerBeginSv1,
159159
)
160160
}
@@ -179,30 +179,16 @@ class UpdateHistoryIntegrationTest
179179
.lookupUserWallet(aliceWalletClient.config.ledgerApiUser)
180180
.futureValue
181181
.getOrElse(throw new RuntimeException("Alice wallet should exist"))
182-
.store
182+
.automation
183183
.updateHistory,
184184
ledgerBeginAlice,
185185
true,
186186
)
187187
}
188-
eventually() {
189-
compareHistory(
190-
sv1Backend.participantClient,
191-
sv1Backend.appState.svStore.updateHistory,
192-
ledgerBeginSv1,
193-
)
194-
}
195-
eventually() {
196-
compareHistory(
197-
sv1Backend.participantClient,
198-
sv1Backend.appState.dsoStore.updateHistory,
199-
ledgerBeginSv1,
200-
)
201-
}
202188
eventually() {
203189
compareHistory(
204190
aliceValidatorBackend.participantClient,
205-
aliceValidatorBackend.appState.store.updateHistory,
191+
aliceValidatorBackend.appState.automation.updateHistory,
206192
ledgerBeginAlice,
207193
)
208194
}

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/WalletTxLogIntegrationTest.scala

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.lfdecentralizedtrust.splice.codegen.java.splice.wallet.subscriptions
77
import org.lfdecentralizedtrust.splice.config.ConfigTransforms
88
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
99
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTestWithSharedEnvironment
10-
import org.lfdecentralizedtrust.splice.store.Limit
10+
import org.lfdecentralizedtrust.splice.store.{Limit, PageLimit}
1111
import org.lfdecentralizedtrust.splice.sv.automation.delegatebased.AnsSubscriptionRenewalPaymentTrigger
1212
import org.lfdecentralizedtrust.splice.sv.config.InitialAnsConfig
1313
import org.lfdecentralizedtrust.splice.util.{
@@ -1226,12 +1226,27 @@ class WalletTxLogIntegrationTest
12261226
logEntry.senderHoldingFees should beWithin(0, smallAmount)
12271227
logEntry.amuletPrice shouldBe amuletPrice
12281228
}
1229+
val expectedTxLogEntries = Seq(renewTxLog, creationTxLog, tapTxLog)
12291230
checkTxHistory(
12301231
bobValidatorWalletClient,
1231-
Seq(renewTxLog, creationTxLog, tapTxLog),
1232+
expectedTxLogEntries,
12321233
trafficTopups = IgnoreTopupsDevNet,
12331234
)
12341235

1236+
clue("Check UpdateHistory works for external parties") {
1237+
inside(
1238+
bobValidatorBackend.appState.walletManager
1239+
.valueOrFail("WalletManager is expected to be defined")
1240+
.externalPartyWalletManager
1241+
.lookupExternalPartyWallet(onboarding.party)
1242+
.valueOrFail(s"Expected ${onboarding.party} to have an external party wallet")
1243+
.updateHistory
1244+
.getAllUpdates(None, PageLimit.Max)
1245+
.futureValue
1246+
) { history =>
1247+
history.size should be >= expectedTxLogEntries.size
1248+
}
1249+
}
12351250
}
12361251

12371252
"handle failed automation (direct transfer)" in { implicit env =>

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/util/UpdateHistoryTestUtil.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ trait UpdateHistoryTestUtil extends TestCommon {
151151
scanBackend: ScanAppBackendReference,
152152
scanClient: ScanAppClientReference,
153153
): Assertion = {
154-
val historyFromStore = scanBackend.appState.store.updateHistory
154+
val historyFromStore = scanBackend.appState.automation.updateHistory
155155
.getAllUpdates(
156156
None,
157157
PageLimit.tryCreate(1000),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
-- if the only store descriptors belong to the SV app or Splitwell, that means we can truncate the update_history tables
2+
3+
DO $$
4+
DECLARE
5+
descriptors TEXT[];
6+
BEGIN
7+
8+
-- array equality (ordered) ensures that exactly the provided descriptors, no more, no less, are there <=> it's the SV app or splitwell
9+
select array_agg(store_name order by store_name) into descriptors
10+
from update_history_descriptors;
11+
12+
IF (descriptors = '{"DbSvDsoStore", "DbSvSvStore"}' OR descriptors = '{"DbSplitwellStore"}') THEN
13+
RAISE NOTICE 'Truncating update history tables as only SV/Splitwell app descriptors are present. Descriptors: %', descriptors::text;
14+
EXECUTE 'TRUNCATE TABLE update_history_assignments CASCADE';
15+
EXECUTE 'TRUNCATE TABLE update_history_unassignments CASCADE';
16+
EXECUTE 'TRUNCATE TABLE update_history_backfilling CASCADE';
17+
EXECUTE 'TRUNCATE TABLE update_history_creates CASCADE';
18+
EXECUTE 'TRUNCATE TABLE update_history_exercises CASCADE';
19+
EXECUTE 'TRUNCATE TABLE update_history_transactions CASCADE';
20+
EXECUTE 'TRUNCATE TABLE update_history_last_ingested_offsets CASCADE';
21+
EXECUTE 'TRUNCATE TABLE update_history_descriptors CASCADE';
22+
ELSE
23+
RAISE NOTICE 'This is not the SV or Splitwell app, NOT truncating update history tables. Descriptors: %', descriptors::text;
24+
END IF;
25+
26+
END $$;

apps/common/src/main/scala/org/lfdecentralizedtrust/splice/automation/AutomationService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import scala.reflect.ClassTag
2323

2424
/** Shared base class for running ingestion and task-handler automation in applications. */
2525
abstract class AutomationService(
26-
private val automationConfig: AutomationConfig,
26+
protected val automationConfig: AutomationConfig,
2727
clock: Clock,
2828
domainTimeSync: DomainTimeSynchronization,
2929
domainUnpausedSync: DomainUnpausedSynchronization,

0 commit comments

Comments
 (0)