Skip to content

Commit 6313161

Browse files
committed
fix: remove redundant getAllocation & getLegacyAllocation functions.
1 parent 708201d commit 6313161

File tree

7 files changed

+21
-43
lines changed

7 files changed

+21
-43
lines changed

packages/subgraph-service/contracts/DisputeManager.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ contract DisputeManager is
431431
// Get attestation signer. Indexers signs with the allocationId
432432
address allocationId = _recoverSigner(attestation);
433433

434-
Allocation.State memory alloc = subgraphService.getAllocation(allocationId);
434+
Allocation.State memory alloc = subgraphService.allocations(allocationId);
435435
require(alloc.indexer != address(0), DisputeManagerIndexerNotFound(allocationId));
436436
require(
437437
alloc.subgraphDeploymentId == attestation.subgraphDeploymentId,
@@ -533,7 +533,7 @@ contract DisputeManager is
533533
require(!isDisputeCreated(disputeId), DisputeManagerDisputeAlreadyCreated(disputeId));
534534

535535
// Allocation must exist
536-
Allocation.State memory alloc = subgraphService.getAllocation(_allocationId);
536+
Allocation.State memory alloc = subgraphService.allocations(_allocationId);
537537
address indexer = alloc.indexer;
538538
require(indexer != address(0), DisputeManagerIndexerNotFound(_allocationId));
539539

packages/subgraph-service/contracts/SubgraphService.sol

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -400,18 +400,11 @@ contract SubgraphService is
400400
emit CurationCutSet(curationCut);
401401
}
402402

403-
/**
404-
* @notice See {ISubgraphService.getAllocation}
405-
*/
406-
function getAllocation(address allocationId) external view override returns (Allocation.State memory) {
407-
return allocations[allocationId];
408-
}
409-
410403
/**
411404
* @notice Get allocation data to calculate rewards issuance
412405
* @dev Implements {IRewardsIssuer.getAllocationData}
413-
* @dev Note that this is slightly different than {getAllocation}. It returns an
414-
* unstructured subset of the allocation data, which is the minimum required to mint rewards.
406+
* @dev Note Returns an unstructured subset of the allocation data,
407+
* which is the minimum required to mint rewards.
415408
*
416409
* Should only be used by the {RewardsManager}.
417410
*
@@ -457,13 +450,6 @@ contract SubgraphService is
457450
return allocations[allocationId].isOpen();
458451
}
459452

460-
/**
461-
* @notice See {ISubgraphService.getLegacyAllocation}
462-
*/
463-
function getLegacyAllocation(address allocationId) external view override returns (LegacyAllocation.State memory) {
464-
return legacyAllocations[allocationId];
465-
}
466-
467453
/**
468454
* @notice See {ISubgraphService.encodeAllocationProof}
469455
*/

packages/subgraph-service/contracts/SubgraphServiceStorage.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ abstract contract SubgraphServiceV1Storage {
1212

1313
/// @notice The cut curators take from query fee payments
1414
uint256 public curationFeesCut;
15+
16+
/// @notice Allocations managed by the service
17+
mapping(address => Allocation.State) public allocations;
18+
19+
/// @notice Legacy allocations managed by the service
20+
mapping(address => LegacyAllocation.State) public legacyAllocations;
1521
}

packages/subgraph-service/contracts/interfaces/ISubgraphService.sol

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,6 @@ interface ISubgraphService is IDataServiceFees {
217217
*/
218218
function setRewardsDestination(address rewardsDestination) external;
219219

220-
/**
221-
* @notice Gets the details of an allocation
222-
* For legacy allocations use {getLegacyAllocation}
223-
* @param allocationId The id of the allocation
224-
*/
225-
function getAllocation(address allocationId) external view returns (Allocation.State memory);
226-
227-
/**
228-
* @notice Gets the details of a legacy allocation
229-
* For non-legacy allocations use {getAllocation}
230-
* @param allocationId The id of the allocation
231-
*/
232-
function getLegacyAllocation(address allocationId) external view returns (LegacyAllocation.State memory);
233-
234220
/**
235221
* @notice Encodes the allocation proof for EIP712 signing
236222
* @param indexer The address of the indexer

packages/subgraph-service/test/disputeManager/DisputeManager.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ contract DisputeManagerTest is SubgraphServiceSharedTest {
6969
bytes32 expectedDisputeId = keccak256(abi.encodePacked(_allocationId, _poi));
7070
uint256 disputeDeposit = disputeManager.disputeDeposit();
7171
uint256 beforeFishermanBalance = token.balanceOf(fisherman);
72-
Allocation.State memory alloc = subgraphService.getAllocation(_allocationId);
72+
Allocation.State memory alloc = subgraphService.allocations(_allocationId);
7373
uint256 stakeSnapshot = disputeManager.getStakeSnapshot(alloc.indexer);
7474

7575
// Approve the dispute deposit

packages/subgraph-service/test/shared/SubgraphServiceShared.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest {
111111
subgraphService.startService(_indexer, _data);
112112

113113
// Check allocation data
114-
Allocation.State memory allocation = subgraphService.getAllocation(allocationId);
114+
Allocation.State memory allocation = subgraphService.allocations(allocationId);
115115
assertEq(allocation.tokens, tokens);
116116
assertEq(allocation.indexer, _indexer);
117117
assertEq(allocation.subgraphDeploymentId, subgraphDeploymentId);
@@ -130,7 +130,7 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest {
130130
address allocationId = abi.decode(_data, (address));
131131
assertTrue(subgraphService.isActiveAllocation(allocationId));
132132

133-
Allocation.State memory allocation = subgraphService.getAllocation(allocationId);
133+
Allocation.State memory allocation = subgraphService.allocations(allocationId);
134134
uint256 previousSubgraphAllocatedTokens = subgraphService.getSubgraphAllocatedTokens(allocation.subgraphDeploymentId);
135135

136136
vm.expectEmit(address(subgraphService));
@@ -141,7 +141,7 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest {
141141
subgraphService.stopService(_indexer, _data);
142142

143143
// update allocation
144-
allocation = subgraphService.getAllocation(allocationId);
144+
allocation = subgraphService.allocations(allocationId);
145145

146146
// check allocation
147147
assertEq(allocation.closedAt, block.timestamp);

packages/subgraph-service/test/subgraphService/SubgraphService.t.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
104104

105105
function _resizeAllocation(address _indexer, address _allocationId, uint256 _tokens) internal {
106106
// before state
107-
Allocation.State memory beforeAllocation = subgraphService.getAllocation(_allocationId);
107+
Allocation.State memory beforeAllocation = subgraphService.allocations(_allocationId);
108108
bytes32 subgraphDeploymentId = beforeAllocation.subgraphDeploymentId;
109109
uint256 beforeSubgraphAllocatedTokens = subgraphService.getSubgraphAllocatedTokens(subgraphDeploymentId);
110110
uint256 beforeAllocatedTokens = subgraphService.allocationProvisionTracker(_indexer);
@@ -131,7 +131,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
131131
// after state
132132
uint256 afterSubgraphAllocatedTokens = subgraphService.getSubgraphAllocatedTokens(subgraphDeploymentId);
133133
uint256 afterAllocatedTokens = subgraphService.allocationProvisionTracker(_indexer);
134-
Allocation.State memory afterAllocation = subgraphService.getAllocation(_allocationId);
134+
Allocation.State memory afterAllocation = subgraphService.allocations(_allocationId);
135135
uint256 accRewardsPerAllocatedTokenDelta = afterAllocation.accRewardsPerAllocatedToken -
136136
beforeAllocation.accRewardsPerAllocatedToken;
137137
uint256 afterAccRewardsPending = rewardsManager.calcRewards(
@@ -154,7 +154,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
154154
function _closeStaleAllocation(address _allocationId) internal {
155155
assertTrue(subgraphService.isActiveAllocation(_allocationId));
156156

157-
Allocation.State memory allocation = subgraphService.getAllocation(_allocationId);
157+
Allocation.State memory allocation = subgraphService.allocations(_allocationId);
158158
uint256 previousSubgraphAllocatedTokens = subgraphService.getSubgraphAllocatedTokens(
159159
allocation.subgraphDeploymentId
160160
);
@@ -171,7 +171,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
171171
subgraphService.closeStaleAllocation(_allocationId);
172172

173173
// update allocation
174-
allocation = subgraphService.getAllocation(_allocationId);
174+
allocation = subgraphService.allocations(_allocationId);
175175

176176
// check allocation
177177
assertEq(allocation.closedAt, block.timestamp);
@@ -231,7 +231,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
231231
// Recover RAV data
232232
ITAPCollector.SignedRAV memory signedRav = abi.decode(_data, (ITAPCollector.SignedRAV));
233233
allocationId = abi.decode(signedRav.rav.metadata, (address));
234-
allocation = subgraphService.getAllocation(allocationId);
234+
allocation = subgraphService.allocations(allocationId);
235235
address payer = _recoverRAVSigner(signedRav);
236236

237237
// Total amount of tokens collected for indexer
@@ -249,7 +249,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
249249
} else if (_paymentType == IGraphPayments.PaymentTypes.IndexingRewards) {
250250
// Recover IndexingRewards data
251251
(allocationId, indexingRewardsData.poi) = abi.decode(_data, (address, bytes32));
252-
allocation = subgraphService.getAllocation(allocationId);
252+
allocation = subgraphService.allocations(allocationId);
253253

254254
// Calculate accumulated tokens, this depends on the rewards manager which we have mocked
255255
uint256 accRewardsPerTokens = allocation.tokens.mulPPM(rewardsManager.rewardsPerSignal());
@@ -332,7 +332,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
332332
assertEq(stakeClaim.nextClaim, bytes32(0));
333333
} else if (_paymentType == IGraphPayments.PaymentTypes.IndexingRewards) {
334334
// Update allocation after collecting rewards
335-
allocation = subgraphService.getAllocation(allocationId);
335+
allocation = subgraphService.allocations(allocationId);
336336

337337
// Check allocation state
338338
assertEq(allocation.accRewardsPending, 0);

0 commit comments

Comments
 (0)