@@ -202,7 +202,11 @@ class Agent {
202202 )
203203
204204 const maxAllocationEpochs = timer ( 600_000 ) . tryMap (
205- ( ) => this . network . contracts . staking . maxAllocationEpochs ( ) ,
205+ ( ) =>
206+ // can i pass these 2 numbers into rule creation?
207+ this . indexer . maxLifetime
208+ ? this . indexer . maxLifetime
209+ : this . network . contracts . staking . maxAllocationEpochs ( ) ,
206210 {
207211 onError : err =>
208212 this . logger . warn ( `Failed to fetch max allocation epochs` , { err } ) ,
@@ -697,7 +701,6 @@ class Agent {
697701
698702 this . logger . info ( `Reconcile allocations` , {
699703 currentEpoch,
700- maxAllocationEpochs,
701704 allocationLifetime,
702705 targetAllocations : targetAllocations . map (
703706 deployment => deployment . display ,
@@ -715,7 +718,7 @@ class Agent {
715718 ...activeAllocations . map ( allocation => allocation . subgraphDeployment . id ) ,
716719 ] )
717720
718- // Ensure the network subgraph is never allocated towards
721+ // Ensure the network subgraph is never allocated towards unless explicitly allowed
719722 if (
720723 ! this . allocateOnNetworkSubgraph &&
721724 this . networkSubgraph . deployment ?. id . bytes32
@@ -757,7 +760,7 @@ class Agent {
757760
758761 currentEpoch ,
759762 currentEpochStartBlock ,
760- maxAllocationEpochs ,
763+ allocationLifetime ,
761764 )
762765 } ,
763766 { concurrency : 1 } ,
@@ -782,6 +785,9 @@ class Agent {
782785 ? BigNumber . from ( rule . allocationAmount )
783786 : this . indexer . defaultAllocationAmount
784787 const desiredNumberOfAllocations = 1
788+ const desiredAllocationLifetime = rule ?. allocationLifetime
789+ ? Math . max ( 1 , rule . allocationLifetime )
790+ : maxAllocationEpochs
785791 const activeAllocationAmount = activeAllocations . reduce (
786792 ( sum , allocation ) => sum . add ( allocation . allocatedTokens ) ,
787793 BigNumber . from ( '0' ) ,
@@ -795,6 +801,7 @@ class Agent {
795801 `Reconcile deployment allocations for deployment '${ deployment . ipfsHash } '` ,
796802 {
797803 desiredAllocationAmount : formatGRT ( desiredAllocationAmount ) ,
804+ desiredAllocationLifetime,
798805
799806 totalActiveAllocationAmount : formatGRT ( activeAllocationAmount ) ,
800807
@@ -881,11 +888,10 @@ class Agent {
881888 )
882889 }
883890
884- const lifetime = Math . max ( 1 , maxAllocationEpochs - 1 )
885-
886891 // For allocations that have expired, let's reallocate in one transaction (closeAndAllocate)
887892 let expiredAllocations = activeAllocations . filter (
888- allocation => epoch >= allocation . createdAtEpoch + lifetime ,
893+ allocation =>
894+ epoch >= allocation . createdAtEpoch + desiredAllocationLifetime ,
889895 )
890896 // The allocations come from the network subgraph; due to short indexing
891897 // latencies, this data may be slightly outdated. Cross-check with the
0 commit comments