@@ -47,7 +47,7 @@ import mapValues from 'lodash.mapvalues'
47
47
import zip from 'lodash.zip'
48
48
import { AgentConfigs , NetworkAndOperator } from './types'
49
49
50
- type ActionReconciliationContext = [ AllocationDecision [ ] , number , number ]
50
+ type ActionReconciliationContext = [ AllocationDecision [ ] , number , bigint ]
51
51
52
52
const deploymentInList = (
53
53
list : SubgraphDeploymentID [ ] ,
@@ -270,15 +270,15 @@ export class Agent {
270
270
} ,
271
271
)
272
272
273
- const maxAllocationEpochs : Eventual < NetworkMapped < number > > =
273
+ const maxAllocationEpochs : Eventual < NetworkMapped < bigint > > =
274
274
sequentialTimerMap (
275
275
{ logger, milliseconds : requestIntervalLarge } ,
276
276
( ) =>
277
277
this . multiNetworks . map ( ( { network } ) => {
278
278
logger . trace ( 'Fetching max allocation epochs' , {
279
279
protocolNetwork : network . specification . networkIdentifier ,
280
280
} )
281
- return network . contracts . staking . maxAllocationEpochs ( )
281
+ return network . contracts . LegacyStaking . maxAllocationEpochs ( )
282
282
} ) ,
283
283
{
284
284
onError : error =>
@@ -304,9 +304,9 @@ export class Agent {
304
304
await network . networkMonitor . subgraphs ( subgraphRuleIds )
305
305
if ( subgraphsMatchingRules . length >= 1 ) {
306
306
const epochLength =
307
- await network . contracts . epochManager . epochLength ( )
307
+ await network . contracts . EpochManager . epochLength ( )
308
308
const blockPeriod = 15
309
- const bufferPeriod = epochLength . toNumber ( ) * blockPeriod * 100 // 100 epochs
309
+ const bufferPeriod = Number ( epochLength ) * blockPeriod * 100 // 100 epochs
310
310
rules = convertSubgraphBasedRulesToDeploymentBased (
311
311
rules ,
312
312
subgraphsMatchingRules ,
@@ -486,7 +486,7 @@ export class Agent {
486
486
const matchingTransfer = eligibleTransferDeployments . find (
487
487
deployment =>
488
488
deployment . ipfsHash == decision . deployment . ipfsHash &&
489
- deployment . startedTransferToL2At . toNumber ( ) > oneWeekAgo ,
489
+ Number ( deployment . startedTransferToL2At ) > oneWeekAgo ,
490
490
)
491
491
if ( matchingTransfer ) {
492
492
logger . debug ( 'Found a matching subgraph transfer' , {
@@ -682,7 +682,8 @@ export class Agent {
682
682
currentEpochNumber : number ,
683
683
) =>
684
684
currentEpochNumber -
685
- network . specification . indexerOptions . poiDisputableEpochs ,
685
+ ( network . specification . indexerOptions
686
+ . poiDisputableEpochs as number ) ,
686
687
)
687
688
688
689
// Find disputable allocations
@@ -821,22 +822,22 @@ export class Agent {
821
822
await network . networkProvider . getBlock (
822
823
pool . previousEpochStartBlockHash ! ,
823
824
)
824
- pool . closedAtEpochStartBlockNumber = closedAtEpochStartBlock . number
825
+ pool . closedAtEpochStartBlockNumber = closedAtEpochStartBlock ! . number
825
826
pool . referencePOI = await this . graphNode . proofOfIndexing (
826
827
pool . subgraphDeployment ,
827
828
{
828
- number : closedAtEpochStartBlock . number ,
829
- hash : closedAtEpochStartBlock . hash ,
829
+ number : closedAtEpochStartBlock ! . number ,
830
+ hash : closedAtEpochStartBlock ! . hash ! ,
830
831
} ,
831
832
pool . allocationIndexer ,
832
833
)
833
- pool . previousEpochStartBlockHash = previousEpochStartBlock . hash
834
- pool . previousEpochStartBlockNumber = previousEpochStartBlock . number
834
+ pool . previousEpochStartBlockHash = previousEpochStartBlock ! . hash !
835
+ pool . previousEpochStartBlockNumber = previousEpochStartBlock ! . number
835
836
pool . referencePreviousPOI = await this . graphNode . proofOfIndexing (
836
837
pool . subgraphDeployment ,
837
838
{
838
- number : previousEpochStartBlock . number ,
839
- hash : previousEpochStartBlock . hash ,
839
+ number : previousEpochStartBlock ! . number ,
840
+ hash : previousEpochStartBlock ! . hash ! ,
840
841
} ,
841
842
pool . allocationIndexer ,
842
843
)
@@ -1006,13 +1007,13 @@ export class Agent {
1006
1007
activeAllocations : Allocation [ ] ,
1007
1008
deploymentAllocationDecision : AllocationDecision ,
1008
1009
epoch : number ,
1009
- maxAllocationEpochs : number ,
1010
+ maxAllocationEpochs : bigint ,
1010
1011
network : Network ,
1011
1012
) : Promise < Allocation [ ] > {
1012
1013
const desiredAllocationLifetime = deploymentAllocationDecision . ruleMatch
1013
1014
. rule ?. allocationLifetime
1014
1015
? deploymentAllocationDecision . ruleMatch . rule . allocationLifetime
1015
- : Math . max ( 1 , maxAllocationEpochs - 1 )
1016
+ : Math . max ( 1 , Number ( maxAllocationEpochs ) - 1 )
1016
1017
1017
1018
// Identify expiring allocations
1018
1019
let expiredAllocations = activeAllocations . filter (
@@ -1028,8 +1029,8 @@ export class Agent {
1028
1029
async ( allocation : Allocation ) => {
1029
1030
try {
1030
1031
const onChainAllocation =
1031
- await network . contracts . staking . getAllocation ( allocation . id )
1032
- return onChainAllocation . closedAtEpoch . eq ( '0' )
1032
+ await network . contracts . LegacyStaking . getAllocation ( allocation . id )
1033
+ return onChainAllocation . closedAtEpoch == 0n
1033
1034
} catch ( err ) {
1034
1035
this . logger . warn (
1035
1036
`Failed to cross-check allocation state with contracts; assuming it needs to be closed` ,
@@ -1050,7 +1051,7 @@ export class Agent {
1050
1051
deploymentAllocationDecision : AllocationDecision ,
1051
1052
activeAllocations : Allocation [ ] ,
1052
1053
epoch : number ,
1053
- maxAllocationEpochs : number ,
1054
+ maxAllocationEpochs : bigint ,
1054
1055
network : Network ,
1055
1056
operator : Operator ,
1056
1057
) : Promise < void > {
@@ -1145,7 +1146,7 @@ export class Agent {
1145
1146
async reconcileActions (
1146
1147
networkDeploymentAllocationDecisions : NetworkMapped < AllocationDecision [ ] > ,
1147
1148
epoch : NetworkMapped < number > ,
1148
- maxAllocationEpochs : NetworkMapped < number > ,
1149
+ maxAllocationEpochs : NetworkMapped < bigint > ,
1149
1150
) : Promise < void > {
1150
1151
// --------------------------------------------------------------------------------
1151
1152
// Filter out networks set to `manual` allocation management mode, and ensure the
0 commit comments