Skip to content

Commit 723b19b

Browse files
committed
common: make scalar optional and turned off when tap is enabled
1 parent 5549148 commit 723b19b

File tree

3 files changed

+57
-33
lines changed

3 files changed

+57
-33
lines changed

packages/indexer-common/src/indexer-management/allocations.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,9 @@ export class AllocationManager {
484484
epoch: createAllocationEventLogs.epoch.toString(),
485485
})
486486

487+
// TODO: deprecated
487488
// Remember allocation
488-
await this.network.receiptCollector.rememberAllocations(actionID, [
489+
await this.network.receiptCollector?.rememberAllocations(actionID, [
489490
createAllocationEventLogs.allocationID,
490491
])
491492

@@ -638,12 +639,16 @@ export class AllocationManager {
638639
logger.info('Identifying receipts worth collecting', {
639640
allocation: closeAllocationEventLogs.allocationID,
640641
})
642+
let isCollectingQueryFees = false
641643
const allocation = await this.network.networkMonitor.allocation(allocationID)
642-
// Collect query fees for this allocation
643-
const isCollectingQueryFees = await this.network.receiptCollector.collectReceipts(
644-
actionID,
645-
allocation,
646-
)
644+
if (this.network.receiptCollector) {
645+
// TODO: deprecated
646+
// Collect query fees for this allocation
647+
isCollectingQueryFees = await this.network.receiptCollector.collectReceipts(
648+
actionID,
649+
allocation,
650+
)
651+
}
647652

648653
// Upsert a rule so the agent keeps the deployment synced but doesn't allocate to it
649654
logger.debug(
@@ -925,11 +930,15 @@ export class AllocationManager {
925930
try {
926931
allocation = await this.network.networkMonitor.allocation(allocationID)
927932
// Collect query fees for this allocation
928-
isCollectingQueryFees = await this.network.receiptCollector.collectReceipts(
929-
actionID,
930-
allocation,
931-
)
932-
logger.debug('Finished receipt collection')
933+
934+
// TODO: deprecated
935+
if (this.network.receiptCollector) {
936+
isCollectingQueryFees = await this.network.receiptCollector.collectReceipts(
937+
actionID,
938+
allocation,
939+
)
940+
logger.debug('Finished receipt collection')
941+
}
933942
} catch (err) {
934943
logger.error('Failed to collect receipts', {
935944
err,

packages/indexer-common/src/indexer-management/resolvers/allocations.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,12 @@ export default {
711711
allocation: closeAllocationEventLogs.allocationID,
712712
})
713713

714+
// TODO: deprecated
714715
// Collect query fees for this allocation
715-
const isCollectingQueryFees = await receiptCollector.collectReceipts(
716-
0,
717-
allocationData,
718-
)
716+
let isCollectingQueryFees = false
717+
if (receiptCollector) {
718+
isCollectingQueryFees = await receiptCollector.collectReceipts(0, allocationData)
719+
}
719720

720721
logger.debug(
721722
`Updating indexing rules, so indexer-agent keeps the deployment synced but doesn't reallocate to it`,
@@ -1016,11 +1017,12 @@ export default {
10161017
allocation: closeAllocationEventLogs.allocationID,
10171018
})
10181019

1019-
// Collect query fees for this allocation
1020-
const isCollectingQueryFees = await receiptCollector.collectReceipts(
1021-
0,
1022-
allocationData,
1023-
)
1020+
// TODO: deprecated
1021+
let isCollectingQueryFees = false
1022+
if (receiptCollector) {
1023+
// Collect query fees for this allocation
1024+
isCollectingQueryFees = await receiptCollector.collectReceipts(0, allocationData)
1025+
}
10241026

10251027
logger.debug(
10261028
`Updating indexing rules, so indexer-agent will now manage the active allocation`,
@@ -1061,6 +1063,7 @@ export default {
10611063
}
10621064
},
10631065

1066+
// TODO: deprecated
10641067
submitCollectReceiptsJob: async (
10651068
{
10661069
allocation,
@@ -1092,7 +1095,10 @@ export default {
10921095
})
10931096

10941097
// Collect query fees for this allocation
1095-
const collecting = await receiptCollector.collectReceipts(0, allocationData)
1098+
let collecting = false
1099+
if (receiptCollector) {
1100+
collecting = await receiptCollector.collectReceipts(0, allocationData)
1101+
}
10961102

10971103
logger.info(`Submitted allocation receipt collection job for execution`, {
10981104
allocationID: allocation,

packages/indexer-common/src/network.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export class Network {
4747
networkProvider: providers.StaticJsonRpcProvider
4848
transactionManager: TransactionManager
4949
networkMonitor: NetworkMonitor
50-
receiptCollector: AllocationReceiptCollector
50+
51+
// TODO: deprecated
52+
receiptCollector: AllocationReceiptCollector | undefined
53+
5154
tapCollector: TapCollector | undefined
5255
specification: spec.NetworkSpecification
5356
paused: Eventual<boolean>
@@ -61,7 +64,7 @@ export class Network {
6164
networkProvider: providers.StaticJsonRpcProvider,
6265
transactionManager: TransactionManager,
6366
networkMonitor: NetworkMonitor,
64-
receiptCollector: AllocationReceiptCollector,
67+
receiptCollector: AllocationReceiptCollector | undefined,
6568
tapCollector: TapCollector | undefined,
6669
specification: spec.NetworkSpecification,
6770
paused: Eventual<boolean>,
@@ -272,16 +275,22 @@ export class Network {
272275
// --------------------------------------------------------------------------------
273276
// * Allocation Receipt Collector
274277
// --------------------------------------------------------------------------------
275-
const scalarCollector = await AllocationReceiptCollector.create({
276-
logger,
277-
metrics,
278-
transactionManager: transactionManager,
279-
models: queryFeeModels,
280-
allocationExchange: contracts.allocationExchange,
281-
allocations,
282-
networkSpecification: specification,
283-
networkSubgraph,
284-
})
278+
let scalarCollector: AllocationReceiptCollector | undefined = undefined
279+
if (!(tapContracts && tapSubgraph)) {
280+
logger.warn(
281+
"deprecated scalar voucher collector is enabled - you probably don't want this",
282+
)
283+
scalarCollector = await AllocationReceiptCollector.create({
284+
logger,
285+
metrics,
286+
transactionManager: transactionManager,
287+
models: queryFeeModels,
288+
allocationExchange: contracts.allocationExchange,
289+
allocations,
290+
networkSpecification: specification,
291+
networkSubgraph,
292+
})
293+
}
285294

286295
// --------------------------------------------------------------------------------
287296
// * TAP Collector

0 commit comments

Comments
 (0)