88 timer ,
99} from '@graphprotocol/common-ts'
1010import {
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 {
4440import PQueue from 'p-queue'
4541import pMap from 'p-map'
4642import pFilter from 'p-filter'
47- import mapValues from 'lodash.mapvalues'
4843import zip from 'lodash.zip'
4944import { 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 ( {
0 commit comments