Skip to content

Commit

Permalink
common: make scalar optional and turned off when tap is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dwerner committed Dec 26, 2024
1 parent 5546056 commit c7b5a5c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 33 deletions.
31 changes: 20 additions & 11 deletions packages/indexer-common/src/indexer-management/allocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,9 @@ export class AllocationManager {
epoch: createAllocationEventLogs.epoch.toString(),
})

// TODO: deprecated
// Remember allocation
await this.network.receiptCollector.rememberAllocations(actionID, [
await this.network.receiptCollector?.rememberAllocations(actionID, [
createAllocationEventLogs.allocationID,
])

Expand Down Expand Up @@ -638,12 +639,16 @@ export class AllocationManager {
logger.info('Identifying receipts worth collecting', {
allocation: closeAllocationEventLogs.allocationID,
})
let isCollectingQueryFees = false
const allocation = await this.network.networkMonitor.allocation(allocationID)
// Collect query fees for this allocation
const isCollectingQueryFees = await this.network.receiptCollector.collectReceipts(
actionID,
allocation,
)
if (this.network.receiptCollector) {
// TODO: deprecated
// Collect query fees for this allocation
isCollectingQueryFees = await this.network.receiptCollector.collectReceipts(
actionID,
allocation,
)
}

// Upsert a rule so the agent keeps the deployment synced but doesn't allocate to it
logger.debug(
Expand Down Expand Up @@ -925,11 +930,15 @@ export class AllocationManager {
try {
allocation = await this.network.networkMonitor.allocation(allocationID)
// Collect query fees for this allocation
isCollectingQueryFees = await this.network.receiptCollector.collectReceipts(
actionID,
allocation,
)
logger.debug('Finished receipt collection')

// TODO: deprecated
if (this.network.receiptCollector) {
isCollectingQueryFees = await this.network.receiptCollector.collectReceipts(
actionID,
allocation,
)
logger.debug('Finished receipt collection')
}
} catch (err) {
logger.error('Failed to collect receipts', {
err,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,12 @@ export default {
allocation: closeAllocationEventLogs.allocationID,
})

// TODO: deprecated
// Collect query fees for this allocation
const isCollectingQueryFees = await receiptCollector.collectReceipts(
0,
allocationData,
)
let isCollectingQueryFees = false
if (receiptCollector) {
isCollectingQueryFees = await receiptCollector.collectReceipts(0, allocationData)
}

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

// Collect query fees for this allocation
const isCollectingQueryFees = await receiptCollector.collectReceipts(
0,
allocationData,
)
// TODO: deprecated
let isCollectingQueryFees = false
if (receiptCollector) {
// Collect query fees for this allocation
isCollectingQueryFees = await receiptCollector.collectReceipts(0, allocationData)
}

logger.debug(
`Updating indexing rules, so indexer-agent will now manage the active allocation`,
Expand Down Expand Up @@ -1061,6 +1063,7 @@ export default {
}
},

// TODO: deprecated
submitCollectReceiptsJob: async (
{
allocation,
Expand Down Expand Up @@ -1092,7 +1095,10 @@ export default {
})

// Collect query fees for this allocation
const collecting = await receiptCollector.collectReceipts(0, allocationData)
let collecting = false
if (receiptCollector) {
collecting = await receiptCollector.collectReceipts(0, allocationData)
}

logger.info(`Submitted allocation receipt collection job for execution`, {
allocationID: allocation,
Expand Down
33 changes: 21 additions & 12 deletions packages/indexer-common/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export class Network {
networkProvider: providers.StaticJsonRpcProvider
transactionManager: TransactionManager
networkMonitor: NetworkMonitor
receiptCollector: AllocationReceiptCollector

// TODO: deprecated
receiptCollector: AllocationReceiptCollector | undefined

tapCollector: TapCollector | undefined
specification: spec.NetworkSpecification
paused: Eventual<boolean>
Expand All @@ -61,7 +64,7 @@ export class Network {
networkProvider: providers.StaticJsonRpcProvider,
transactionManager: TransactionManager,
networkMonitor: NetworkMonitor,
receiptCollector: AllocationReceiptCollector,
receiptCollector: AllocationReceiptCollector | undefined,
tapCollector: TapCollector | undefined,
specification: spec.NetworkSpecification,
paused: Eventual<boolean>,
Expand Down Expand Up @@ -272,16 +275,22 @@ export class Network {
// --------------------------------------------------------------------------------
// * Allocation Receipt Collector
// --------------------------------------------------------------------------------
const scalarCollector = await AllocationReceiptCollector.create({
logger,
metrics,
transactionManager: transactionManager,
models: queryFeeModels,
allocationExchange: contracts.allocationExchange,
allocations,
networkSpecification: specification,
networkSubgraph,
})
let scalarCollector: AllocationReceiptCollector | undefined = undefined
if (!(tapContracts && tapSubgraph)) {
logger.warn(
"deprecated scalar voucher collector is enabled - you probably don't want this",
)
scalarCollector = await AllocationReceiptCollector.create({
logger,
metrics,
transactionManager: transactionManager,
models: queryFeeModels,
allocationExchange: contracts.allocationExchange,
allocations,
networkSpecification: specification,
networkSubgraph,
})
}

// --------------------------------------------------------------------------------
// * TAP Collector
Expand Down

0 comments on commit c7b5a5c

Please sign in to comment.