Skip to content

Commit e7e4542

Browse files
committed
refactor: remove obsolete L1→L2 auto migration support
The L1 to L2 transfer period has ended, making this feature unnecessary. Removed: - TransferredSubgraphDeployment type and related imports - networkIsL1/networkIsL2 helper functions - transferredDeployments() method from NetworkMonitor - L2_TRANSFER_SUPPORT from ActivationCriteria enum - --enable-auto-migration-support CLI option - autoMigrationSupport from Agent class and AgentConfigs - eligibleTransferDeployments Eventual and L1→L2 merge logic - Network layer detection tests This removes ~300 lines of dead code and simplifies the allocation decision flow by eliminating the intermediate transfer processing step.
1 parent a08d405 commit e7e4542

9 files changed

Lines changed: 24 additions & 333 deletions

File tree

packages/indexer-agent/src/agent.ts

Lines changed: 24 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
timer,
99
} from '@graphprotocol/common-ts'
1010
import {
11-
ActivationCriteria,
1211
ActionStatus,
1312
Allocation,
1413
AllocationManagementMode,
@@ -32,9 +31,6 @@ import {
3231
validateProviderNetworkIdentifier,
3332
MultiNetworks,
3433
NetworkMapped,
35-
TransferredSubgraphDeployment,
36-
networkIsL2,
37-
networkIsL1,
3834
DeploymentManagementMode,
3935
SubgraphStatus,
4036
sequentialTimerMap,
@@ -44,7 +40,6 @@ import {
4440
import PQueue from 'p-queue'
4541
import pMap from 'p-map'
4642
import pFilter from 'p-filter'
47-
import mapValues from 'lodash.mapvalues'
4843
import zip from 'lodash.zip'
4944
import { AgentConfigs, NetworkAndOperator } from './types'
5045

@@ -194,7 +189,6 @@ export class Agent {
194189
multiNetworks: MultiNetworks<NetworkAndOperator>
195190
indexerManagement: IndexerManagementClient
196191
offchainSubgraphs: SubgraphDeploymentID[]
197-
autoMigrationSupport: boolean
198192
deploymentManagement: DeploymentManagementMode
199193
pollingInterval: number
200194

@@ -208,7 +202,6 @@ export class Agent {
208202
configs.operators,
209203
)
210204
this.offchainSubgraphs = configs.offchainSubgraphs
211-
this.autoMigrationSupport = !!configs.autoMigrationSupport
212205
this.deploymentManagement = configs.deploymentManagement
213206
this.pollingInterval = configs.pollingInterval
214207
}
@@ -377,69 +370,36 @@ export class Agent {
377370
},
378371
)
379372

380-
const eligibleTransferDeployments: Eventual<
381-
NetworkMapped<TransferredSubgraphDeployment[]>
382-
> = sequentialTimerMap(
383-
{ logger, milliseconds: requestIntervalLarge },
384-
async () => {
385-
// Return early if the auto migration feature is disabled.
386-
if (!this.autoMigrationSupport) {
387-
logger.trace(
388-
'Auto Migration feature is disabled, skipping querying transferred subgraphs',
389-
)
390-
return this.multiNetworks.map(async () => [])
391-
}
392-
393-
const statuses = await this.graphNode.indexingStatus([])
394-
return this.multiNetworks.map(async ({ network }) => {
395-
const protocolNetwork = network.specification.networkIdentifier
396-
logger.trace('Fetching deployments eligible for L2 transfer', {
397-
protocolNetwork,
398-
})
399-
const transfers =
400-
await network.networkMonitor.transferredDeployments()
401-
logger.trace(
402-
`Found ${transfers.length} transferred subgraphs in the network`,
403-
{ protocolNetwork },
404-
)
405-
return transfers
406-
.map(transfer => {
407-
const status = statuses.find(
408-
status =>
409-
status.subgraphDeployment.ipfsHash == transfer.ipfsHash,
410-
)
411-
if (status) {
412-
transfer.ready = status.synced && status.health == 'healthy'
413-
}
414-
return transfer
415-
})
416-
.filter(transfer => transfer.ready == true)
417-
})
418-
},
419-
{
420-
onError: error =>
421-
logger.warn(
422-
`Failed to obtain transferred deployments, trying again later`,
423-
{ error },
424-
),
425-
},
426-
)
427-
428-
// While in the L1 -> L2 transfer period this will be an intermediate value
429-
// with the final value including transfer considerations
430-
const intermediateNetworkDeploymentAllocationDecisions: Eventual<
373+
const networkDeploymentAllocationDecisions: Eventual<
431374
NetworkMapped<AllocationDecision[]>
432375
> = join({
433376
networkDeployments,
434377
indexingRules,
435378
}).tryMap(
436-
({ indexingRules, networkDeployments }) => {
437-
return mapValues(
379+
async ({ indexingRules, networkDeployments }) => {
380+
return this.multiNetworks.mapNetworkMapped(
438381
this.multiNetworks.zip(indexingRules, networkDeployments),
439-
([indexingRules, networkDeployments]: [
440-
IndexingRuleAttributes[],
441-
SubgraphDeployment[],
442-
]) => {
382+
async (
383+
{ network }: NetworkAndOperator,
384+
[indexingRules, networkDeployments]: [
385+
IndexingRuleAttributes[],
386+
SubgraphDeployment[],
387+
],
388+
) => {
389+
// Skip evaluation entirely for networks in manual allocation mode
390+
if (
391+
network.specification.indexerOptions.allocationManagementMode ===
392+
AllocationManagementMode.MANUAL
393+
) {
394+
logger.trace(
395+
`Skipping deployment evaluation since AllocationManagementMode = 'manual'`,
396+
{
397+
protocolNetwork: network.specification.networkIdentifier,
398+
},
399+
)
400+
return []
401+
}
402+
443403
// Identify subgraph deployments on the network that are worth picking up;
444404
// these may overlap with the ones we're already indexing
445405
logger.trace('Evaluating which deployments are worth allocating to')
@@ -457,94 +417,6 @@ export class Agent {
457417
},
458418
)
459419

460-
// Update targetDeployments and networkDeplomentAllocationDecisions using transferredSubgraphDeployments data
461-
// This will be somewhat custom and will likely be yanked out later after the transfer stage is complete
462-
// Cases:
463-
// - L1 subgraph that had the transfer started: keep synced and allocated to for at least one week
464-
// post transfer.
465-
// - L2 subgraph that has been transferred:
466-
// - if already synced, allocate to it immediately using default allocation amount
467-
// - if not synced, no changes
468-
const networkDeploymentAllocationDecisions: Eventual<
469-
NetworkMapped<AllocationDecision[]>
470-
> = join({
471-
intermediateNetworkDeploymentAllocationDecisions,
472-
eligibleTransferDeployments,
473-
}).tryMap(
474-
({
475-
intermediateNetworkDeploymentAllocationDecisions,
476-
eligibleTransferDeployments,
477-
}) =>
478-
mapValues(
479-
this.multiNetworks.zip(
480-
intermediateNetworkDeploymentAllocationDecisions,
481-
eligibleTransferDeployments,
482-
),
483-
([allocationDecisions, eligibleTransferDeployments]: [
484-
AllocationDecision[],
485-
TransferredSubgraphDeployment[],
486-
]) => {
487-
logger.debug(
488-
`Found ${eligibleTransferDeployments.length} deployments eligible for transfer`,
489-
{ eligibleTransferDeployments },
490-
)
491-
const oneWeekAgo = Math.floor(Date.now() / 1_000) - 86_400 * 7
492-
return allocationDecisions.map(decision => {
493-
const matchingTransfer = eligibleTransferDeployments.find(
494-
deployment =>
495-
deployment.ipfsHash == decision.deployment.ipfsHash &&
496-
Number(deployment.startedTransferToL2At) > oneWeekAgo,
497-
)
498-
if (matchingTransfer) {
499-
logger.debug('Found a matching subgraph transfer', {
500-
matchingTransfer,
501-
})
502-
// L1 deployments being transferred need to be supported for one week post transfer
503-
// to ensure continued support.
504-
if (networkIsL1(matchingTransfer.protocolNetwork)) {
505-
decision.toAllocate = true
506-
decision.ruleMatch.activationCriteria =
507-
ActivationCriteria.L2_TRANSFER_SUPPORT
508-
logger.debug(
509-
`Allocating towards L1 subgraph deployment to support its transfer`,
510-
{
511-
subgraphDeployment: matchingTransfer,
512-
allocationDecision: decision,
513-
},
514-
)
515-
}
516-
// L2 Deployments
517-
if (
518-
networkIsL2(matchingTransfer.protocolNetwork) &&
519-
!!matchingTransfer.transferredToL2
520-
) {
521-
decision.toAllocate = true
522-
decision.ruleMatch.activationCriteria =
523-
ActivationCriteria.L2_TRANSFER_SUPPORT
524-
logger.debug(
525-
`Allocating towards transferred L2 subgraph deployment`,
526-
{
527-
subgraphDeployment: matchingTransfer,
528-
allocationDecision: decision,
529-
},
530-
)
531-
}
532-
}
533-
return decision
534-
})
535-
},
536-
),
537-
{
538-
onError: error =>
539-
logger.warn(
540-
`Failed to merge L2 transfer decisions, trying again later`,
541-
{
542-
error,
543-
},
544-
),
545-
},
546-
)
547-
548420
// let targetDeployments be an union of targetAllocations
549421
// and offchain subgraphs.
550422
const targetDeployments: Eventual<SubgraphDeploymentID[]> = join({

packages/indexer-agent/src/commands/common-options.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,6 @@ export function injectCommonStartupOptions(argv: Argv): Argv {
135135
required: true,
136136
group: 'Indexer Infrastructure',
137137
})
138-
.option('enable-auto-migration-support', {
139-
description:
140-
'Auto migrate allocations from L1 to L2 (multi-network mode must be enabled)',
141-
type: 'boolean',
142-
required: false,
143-
default: false,
144-
group: 'Indexer Infrastructure',
145-
})
146138
.option('deployment-management', {
147139
describe: 'Subgraph deployments management mode',
148140
required: false,

packages/indexer-agent/src/commands/start.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ export async function run(
688688
indexerManagement: indexerManagementClient,
689689
networks,
690690
deploymentManagement: argv.deploymentManagement,
691-
autoMigrationSupport: argv.enableAutoMigrationSupport,
692691
offchainSubgraphs: argv.offchainSubgraphs.map(
693692
(s: string) => new SubgraphDeploymentID(s),
694693
),

packages/indexer-agent/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface AgentConfigs {
2222
indexerManagement: IndexerManagementClient
2323
networks: Network[]
2424
deploymentManagement: DeploymentManagementMode
25-
autoMigrationSupport: boolean
2625
offchainSubgraphs: SubgraphDeploymentID[]
2726
pollingInterval: number
2827
}

packages/indexer-common/src/indexer-management/__tests__/helpers.test.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
IndexingRuleAttributes,
1313
} from '../models'
1414
import { defineQueryFeeModels, specification as spec } from '../../index'
15-
import { networkIsL1, networkIsL2 } from '../types'
1615
import { fetchIndexingRules, upsertIndexingRule } from '../rules'
1716
import { SubgraphFreshnessChecker, SubgraphIdentifierType } from '../../subgraphs'
1817
import { ActionManager } from '../actions'
@@ -505,51 +504,3 @@ describe.skip('Monitor: CI', () => {
505504
await expect(deployments.length).toBeGreaterThan(500)
506505
}, 40000)
507506
})
508-
509-
describe('Network layer detection', () => {
510-
interface NetworkLayer {
511-
name: string
512-
l1: boolean
513-
l2: boolean
514-
}
515-
516-
// Should be true for L1 and false for L2
517-
const l1Networks: NetworkLayer[] = ['mainnet', 'eip155:1', 'sepolia'].map(
518-
(name: string) => ({ name, l1: true, l2: false }),
519-
)
520-
521-
// Should be false for L1 and true for L2
522-
const l2Networks: NetworkLayer[] = [
523-
'arbitrum-one',
524-
'eip155:42161',
525-
'eip155:421614',
526-
].map((name: string) => ({ name, l1: false, l2: true }))
527-
528-
// Those will be false for L1 and L2
529-
const nonProtocolNetworks: NetworkLayer[] = [
530-
'fantom',
531-
'eip155:250',
532-
'hardhat',
533-
'eip155:1337',
534-
'matic',
535-
'eip155:137',
536-
'gnosis',
537-
'eip155:100',
538-
].map((name: string) => ({ name, l1: false, l2: false }))
539-
540-
const testCases = [...l1Networks, ...l2Networks, ...nonProtocolNetworks]
541-
542-
test.each(testCases)('Can detect network layer [$name]', (network) => {
543-
expect(networkIsL1(network.name)).toStrictEqual(network.l1)
544-
expect(networkIsL2(network.name)).toStrictEqual(network.l2)
545-
})
546-
547-
const invalidTProtocolNetworkNames = ['invalid-name', 'eip155:9999']
548-
549-
test.each(invalidTProtocolNetworkNames)(
550-
'Throws error when protocol network is unknown [%s]',
551-
(invalidProtocolNetworkName) => {
552-
expect(() => networkIsL1(invalidProtocolNetworkName)).toThrow()
553-
},
554-
)
555-
})

0 commit comments

Comments
 (0)