@@ -803,8 +803,8 @@ async function closeHorizonAllocation(
803
803
const closeAllocationEventLogs = transactionManager . findEvent (
804
804
'ServiceStopped' ,
805
805
contracts . SubgraphService . interface ,
806
- 'data ' ,
807
- closeAllocationData ,
806
+ 'serviceProvider ' ,
807
+ address ,
808
808
receipt ,
809
809
logger ,
810
810
)
@@ -840,6 +840,7 @@ async function closeHorizonAllocation(
840
840
return { txHash : receipt . hash , rewardsAssigned }
841
841
}
842
842
843
+ // isHorizon: false
843
844
async function reallocateLegacyAllocation (
844
845
allocation : Allocation ,
845
846
allocationAmount : bigint ,
@@ -1056,6 +1057,7 @@ async function reallocateLegacyAllocation(
1056
1057
return { txHash : receipt . hash , rewardsAssigned, newAllocationId }
1057
1058
}
1058
1059
1060
+ // isHorizon: true and allocation: not legacy
1059
1061
async function reallocateHorizonAllocation (
1060
1062
allocation : Allocation ,
1061
1063
allocationAmount : bigint ,
@@ -1073,20 +1075,6 @@ async function reallocateHorizonAllocation(
1073
1075
// Double-check whether the allocation is still active on chain, to
1074
1076
// avoid unnecessary transactions.
1075
1077
const allocationData = await contracts . SubgraphService . getAllocation ( allocation . id )
1076
- const legacyAllocation = await contracts . SubgraphService . getLegacyAllocation (
1077
- allocation . id ,
1078
- )
1079
- const existsSubgraphService = allocationData . createdAt !== 0n
1080
- const existsLegacyAllocation = legacyAllocation . indexer !== ZeroAddress
1081
- if ( existsSubgraphService || existsLegacyAllocation ) {
1082
- logger . warn ( `Skipping allocation as it already exists onchain` , {
1083
- indexer : address ,
1084
- allocation : allocation . id ,
1085
- existsSubgraphService,
1086
- existsLegacyAllocation,
1087
- } )
1088
- throw indexerError ( IndexerErrorCode . IE066 , 'AllocationID already exists' )
1089
- }
1090
1078
1091
1079
if ( allocationData . closedAt !== 0n ) {
1092
1080
logger . warn ( `Allocation has already been closed` )
@@ -1254,8 +1242,8 @@ async function reallocateHorizonAllocation(
1254
1242
const createAllocationEventLogs = network . transactionManager . findEvent (
1255
1243
'ServiceStarted' ,
1256
1244
network . contracts . SubgraphService . interface ,
1257
- 'data ' ,
1258
- createAllocationData ,
1245
+ 'serviceProvider ' ,
1246
+ address ,
1259
1247
receipt ,
1260
1248
logger ,
1261
1249
)
@@ -1292,8 +1280,8 @@ async function reallocateHorizonAllocation(
1292
1280
const closeAllocationEventLogs = transactionManager . findEvent (
1293
1281
'ServiceStopped' ,
1294
1282
contracts . SubgraphService . interface ,
1295
- 'data ' ,
1296
- closeAllocationData ,
1283
+ 'serviceProvider ' ,
1284
+ address ,
1297
1285
receipt ,
1298
1286
logger ,
1299
1287
)
@@ -1322,6 +1310,7 @@ async function reallocateHorizonAllocation(
1322
1310
return { txHash : receipt . hash , rewardsAssigned, newAllocationId }
1323
1311
}
1324
1312
1313
+ // isHorizon: true and allocation: legacy
1325
1314
async function migrateLegacyAllocationToHorizon (
1326
1315
allocation : Allocation ,
1327
1316
allocationAmount : bigint ,
@@ -1487,11 +1476,16 @@ export default {
1487
1476
1488
1477
try {
1489
1478
const currentEpoch = await network . contracts . EpochManager . currentEpoch ( )
1479
+ const isHorizon = await network . isHorizon . value ( )
1480
+
1481
+ logger . debug ( 'createAllocation: Checking allocation resolution path' , {
1482
+ isHorizon,
1483
+ } )
1490
1484
1491
1485
let txHash : string
1492
1486
let allocationId : Address
1493
- if ( await network . isHorizon . value ( ) ) {
1494
- logger . info ( 'Creating horizon allocation' )
1487
+ if ( isHorizon ) {
1488
+ logger . debug ( 'Creating horizon allocation' )
1495
1489
const result = await createHorizonAllocation (
1496
1490
network ,
1497
1491
graphNode ,
@@ -1505,6 +1499,7 @@ export default {
1505
1499
txHash = result . txHash
1506
1500
allocationId = result . allocationId
1507
1501
} else {
1502
+ logger . debug ( 'Creating legacy allocation' )
1508
1503
const result = await createLegacyAllocation (
1509
1504
network ,
1510
1505
graphNode ,
@@ -1603,16 +1598,22 @@ export default {
1603
1598
)
1604
1599
logger . debug ( 'POI resolved' , {
1605
1600
userProvidedPOI : poi ,
1601
+ userProvidedPublicPOI : publicPOI ,
1606
1602
userProvidedBlockNumber : blockNumber ,
1607
1603
poi : poiData . poi ,
1608
1604
publicPOI : poiData . publicPOI ,
1609
1605
blockNumber : poiData . blockNumber ,
1610
1606
force,
1611
1607
} )
1612
1608
1609
+ logger . debug ( 'closeAllocation: Checking allocation resolution path' , {
1610
+ allocationIsLegacy : allocationData . isLegacy ,
1611
+ } )
1612
+
1613
1613
let txHash : string
1614
1614
let rewardsAssigned : bigint
1615
1615
if ( allocationData . isLegacy ) {
1616
+ logger . debug ( 'Closing legacy allocation' )
1616
1617
const result = await closeLegacyAllocation (
1617
1618
allocationData ,
1618
1619
poiData . poi ,
@@ -1622,6 +1623,7 @@ export default {
1622
1623
txHash = result . txHash
1623
1624
rewardsAssigned = result . rewardsAssigned
1624
1625
} else {
1626
+ logger . debug ( 'Closing horizon allocation' )
1625
1627
const result = await closeHorizonAllocation (
1626
1628
allocationData ,
1627
1629
poiData ,
@@ -1736,6 +1738,7 @@ export default {
1736
1738
)
1737
1739
logger . debug ( 'POI resolved' , {
1738
1740
userProvidedPOI : poi ,
1741
+ userProvidedPublicPOI : publicPOI ,
1739
1742
userProvidedBlockNumber : blockNumber ,
1740
1743
poi : poiData . poi ,
1741
1744
publicPOI : poiData . publicPOI ,
@@ -1745,10 +1748,16 @@ export default {
1745
1748
1746
1749
const isHorizon = await network . isHorizon . value ( )
1747
1750
1751
+ logger . debug ( 'reallocateAllocation: Checking allocation resolution path' , {
1752
+ isHorizon,
1753
+ allocationIsLegacy : allocationData . isLegacy ,
1754
+ } )
1755
+
1748
1756
let txHash : string
1749
1757
let rewardsAssigned : bigint
1750
1758
let newAllocationId : Address
1751
1759
if ( ! isHorizon ) {
1760
+ logger . debug ( 'Reallocating legacy allocation' )
1752
1761
const result = await reallocateLegacyAllocation (
1753
1762
allocationData ,
1754
1763
allocationAmount ,
@@ -1761,6 +1770,7 @@ export default {
1761
1770
rewardsAssigned = result . rewardsAssigned
1762
1771
newAllocationId = result . newAllocationId
1763
1772
} else if ( allocationData . isLegacy ) {
1773
+ logger . debug ( 'Migrating legacy allocation to horizon' )
1764
1774
const result = await migrateLegacyAllocationToHorizon (
1765
1775
allocationData ,
1766
1776
allocationAmount ,
@@ -1774,6 +1784,7 @@ export default {
1774
1784
rewardsAssigned = result . rewardsAssigned
1775
1785
newAllocationId = result . newAllocationId
1776
1786
} else {
1787
+ logger . debug ( 'Reallocating horizon allocation' )
1777
1788
const result = await reallocateHorizonAllocation (
1778
1789
allocationData ,
1779
1790
allocationAmount ,
0 commit comments