Skip to content

Commit 94e18ca

Browse files
committed
[ci] Report the earliest round for which there is a complete set of activity records
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
1 parent bf6b5fd commit 94e18ca

File tree

6 files changed

+22
-46
lines changed

6 files changed

+22
-46
lines changed

apps/scan/src/main/openapi/scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ paths:
16281628
description: |
16291629
SV node internal API (CIP-0104, subject to change).
16301630
Returns the earliest round for which CIP-0104 reward accounting activity
1631-
totals are available.
1631+
records are complete.
16321632
responses:
16331633
"200":
16341634
description: ok

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/ScanApp.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ class ScanApp(
369369
automation,
370370
updateHistory,
371371
appRewardsStore,
372+
appActivityRecordStoreO,
372373
acsSnapshotStore,
373374
scanEventStore,
374375
bulkStorage,

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/admin/http/HttpScanHandler.scala

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import org.lfdecentralizedtrust.splice.http.v0.scan.ScanResource
5050
import org.lfdecentralizedtrust.splice.http.v0.{definitions, scan as v0}
5151
import org.lfdecentralizedtrust.splice.scan.store.{
5252
AcsSnapshotStore,
53+
AppActivityStore,
5354
ScanEventStore,
5455
ScanStore,
5556
TxLogEntry,
@@ -130,6 +131,7 @@ class HttpScanHandler(
130131
protected val storeWithIngestion: AppStoreWithIngestion[ScanStore],
131132
updateHistory: UpdateHistory,
132133
appRewardsStore: DbScanAppRewardsStore,
134+
appActivityStoreO: Option[AppActivityStore],
133135
snapshotStore: AcsSnapshotStore,
134136
eventStore: ScanEventStore,
135137
bulkStorage: BulkStorage,
@@ -2377,14 +2379,23 @@ class HttpScanHandler(
23772379
] = {
23782380
implicit val tc = extracted
23792381
withSpan(s"$workflowId.getRewardAccountingEarliestAvailableRound") { _ => _ =>
2380-
appRewardsStore.getEarliestRoundWithActivityTotals().map {
2381-
case Some(round) =>
2382-
ScanResource.GetRewardAccountingEarliestAvailableRoundResponse.OK(
2383-
definitions.GetRewardAccountingEarliestAvailableRoundResponse(round)
2384-
)
2382+
appActivityStoreO match {
2383+
case Some(appActivityStore) =>
2384+
appActivityStore.earliestRoundWithCompleteAppActivity().map {
2385+
case Some(round) =>
2386+
ScanResource.GetRewardAccountingEarliestAvailableRoundResponse.OK(
2387+
definitions.GetRewardAccountingEarliestAvailableRoundResponse(round)
2388+
)
2389+
case None =>
2390+
ScanResource.GetRewardAccountingEarliestAvailableRoundResponse.NotFound(
2391+
ErrorResponse("No reward accounting data available yet")
2392+
)
2393+
}
23852394
case None =>
2386-
ScanResource.GetRewardAccountingEarliestAvailableRoundResponse.NotFound(
2387-
ErrorResponse("No reward accounting data available yet")
2395+
Future.successful(
2396+
ScanResource.GetRewardAccountingEarliestAvailableRoundResponse.NotFound(
2397+
ErrorResponse("Reward accounting is not enabled")
2398+
)
23882399
)
23892400
}
23902401
}

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/automation/RewardComputationTrigger.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import scala.concurrent.{ExecutionContext, Future}
2424
* 2. Compute reward totals (CC minting allowances with threshold filtering)
2525
* 3. Build the Merkle tree of batched reward hashes
2626
*
27-
* TODO(#4118): use ScanRewardsReferenceStore for synchronization in computeRewards needs it
27+
* TODO(#4118): use ScanRewardsReferenceStore for synchronization when computeRewards requires it
2828
*/
2929
class RewardComputationTrigger(
3030
appRewardsStore: ScanAppRewardsStore,

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/store/db/DbScanAppRewardsStore.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -477,18 +477,6 @@ class DbScanAppRewardsStore(
477477
)
478478
}
479479

480-
def getEarliestRoundWithActivityTotals()(implicit
481-
tc: TraceContext
482-
): Future[Option[Long]] = {
483-
val historyId = updateHistory.historyId
484-
runQuerySingle(
485-
sql"""select min(round_number) from #${Tables.appActivityRoundTotals}
486-
where history_id = $historyId
487-
""".as[Option[Long]].headOption.map(_.flatten),
488-
"appRewards.getEarliestRoundWithActivityTotals",
489-
)
490-
}
491-
492480
/** Runs the full reward computation pipeline for a single round.
493481
*
494482
* TODO(#4384): Will be extended to run CC conversion (stage 2) and

apps/scan/src/test/scala/org/lfdecentralizedtrust/splice/scan/store/DbScanAppRewardsStoreTest.scala

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -429,31 +429,7 @@ class DbScanAppRewardsStoreTest
429429
}
430430
}
431431

432-
// -- lookupLatestRoundWithRewardComputation / getEarliestRoundWithActivityTotals ------
433-
434-
"getEarliestRoundWithActivityTotals returns None when empty" in {
435-
for {
436-
(store, historyId) <- newStore()
437-
result <- store.getEarliestRoundWithActivityTotals()
438-
} yield {
439-
result shouldBe None
440-
}
441-
}
442-
443-
"getEarliestRoundWithActivityTotals with data" in {
444-
for {
445-
(store, historyId) <- newStore()
446-
_ <- insertSentinelRecords(historyId, 10L)
447-
_ <- insertSentinelRecords(historyId, 20L)
448-
_ <- insertActivityRecord(historyId, 10L, Seq("alice::provider"), Seq(100L))
449-
_ <- insertActivityRecord(historyId, 20L, Seq("alice::provider"), Seq(200L))
450-
_ <- store.aggregateActivityTotals(10L)
451-
_ <- store.aggregateActivityTotals(20L)
452-
earliest <- store.getEarliestRoundWithActivityTotals()
453-
} yield {
454-
earliest.value shouldBe 10L
455-
}
456-
}
432+
// -- lookupLatestRoundWithRewardComputation ------
457433

458434
"lookupLatestRoundWithRewardComputation returns None when no root hashes" in {
459435
for {

0 commit comments

Comments
 (0)