Skip to content

Commit 753442f

Browse files
f: smaller contract size
1 parent 99ca09c commit 753442f

File tree

19 files changed

+709
-634
lines changed

19 files changed

+709
-634
lines changed

IndexingPaymentsTodo.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Check code coverage
55
* Check contract size
66
* Don't love cancel agreement on stop service / close stale allocation.
7+
* Missing Upgrade event for subgraph service
78

89
# Done
910

packages/horizon/contracts/utilities/GraphDirectory.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ abstract contract GraphDirectory {
131131
);
132132
}
133133

134+
/**
135+
* @notice Get the Epoch Manager contract
136+
* @return The Epoch Manager contract
137+
*/
138+
function graphEpochManager() external view returns (IEpochManager) {
139+
return _graphEpochManager();
140+
}
141+
134142
/**
135143
* @notice Get the Graph Token contract
136144
* @return The Graph Token contract

packages/horizon/test/utilities/GraphDirectoryImplementation.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ contract GraphDirectoryImplementation is GraphDirectory {
2222
function getContractFromController(bytes memory contractName) external view returns (address) {
2323
return _graphController().getContractProxy(keccak256(contractName));
2424
}
25+
2526
function graphToken() external view returns (IGraphToken) {
2627
return _graphToken();
2728
}
@@ -42,10 +43,6 @@ contract GraphDirectoryImplementation is GraphDirectory {
4243
return _graphController();
4344
}
4445

45-
function graphEpochManager() external view returns (IEpochManager) {
46-
return _graphEpochManager();
47-
}
48-
4946
function graphRewardsManager() external view returns (IRewardsManager) {
5047
return _graphRewardsManager();
5148
}

packages/subgraph-service/contracts/Decoder.sol

Lines changed: 0 additions & 105 deletions
This file was deleted.

packages/subgraph-service/contracts/DisputeManager.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { IGraphToken } from "@graphprotocol/contracts/contracts/token/IGraphToke
55
import { IHorizonStaking } from "@graphprotocol/horizon/contracts/interfaces/IHorizonStaking.sol";
66
import { IDisputeManager } from "./interfaces/IDisputeManager.sol";
77
import { ISubgraphService } from "./interfaces/ISubgraphService.sol";
8-
import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol";
98

109
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
1110
import { TokenUtils } from "@graphprotocol/contracts/contracts/utils/TokenUtils.sol";
1211
import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol";
1312
import { MathUtils } from "@graphprotocol/horizon/contracts/libraries/MathUtils.sol";
1413
import { Allocation } from "./libraries/Allocation.sol";
1514
import { Attestation } from "./libraries/Attestation.sol";
15+
import { IndexingAgreement } from "./libraries/IndexingAgreement.sol";
1616

1717
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
1818
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
@@ -480,25 +480,25 @@ contract DisputeManager is
480480
bytes32 _poi,
481481
uint256 _entities
482482
) private returns (bytes32) {
483-
(
484-
ISubgraphService.IndexingAgreementData memory indexingAgreement,
485-
IRecurringCollector.AgreementData memory agreement
486-
) = _getSubgraphService().getIndexingAgreement(_agreementId);
483+
IndexingAgreement.AgreementWrapper memory wrapper = _getSubgraphService().getIndexingAgreement(_agreementId);
487484

488485
// Agreement must have been collected on and be a version 1
489-
require(agreement.lastCollectionAt > 0, DisputeManagerIndexingAgreementNotDisputable(_agreementId));
490486
require(
491-
indexingAgreement.version == ISubgraphService.IndexingAgreementVersion.V1,
492-
DisputeManagerIndexingAgreementInvalidVersion(indexingAgreement.version)
487+
wrapper.collectorAgreement.lastCollectionAt > 0,
488+
DisputeManagerIndexingAgreementNotDisputable(_agreementId)
489+
);
490+
require(
491+
wrapper.agreement.version == IndexingAgreement.IndexingAgreementVersion.V1,
492+
DisputeManagerIndexingAgreementInvalidVersion(wrapper.agreement.version)
493493
);
494494

495495
// Create a disputeId
496496
bytes32 disputeId = keccak256(
497497
abi.encodePacked(
498498
"IndexingFeeDisputeWithAgreement",
499499
_agreementId,
500-
agreement.serviceProvider,
501-
agreement.payer,
500+
wrapper.collectorAgreement.serviceProvider,
501+
wrapper.collectorAgreement.payer,
502502
_poi,
503503
_entities
504504
)
@@ -509,14 +509,14 @@ contract DisputeManager is
509509

510510
// The indexer must be disputable
511511
IHorizonStaking.Provision memory provision = _graphStaking().getProvision(
512-
agreement.serviceProvider,
512+
wrapper.collectorAgreement.serviceProvider,
513513
address(_getSubgraphService())
514514
);
515515
require(provision.tokens != 0, DisputeManagerZeroTokens());
516516

517-
uint256 stakeSnapshot = _getStakeSnapshot(agreement.serviceProvider, provision.tokens);
517+
uint256 stakeSnapshot = _getStakeSnapshot(wrapper.collectorAgreement.serviceProvider, provision.tokens);
518518
disputes[disputeId] = Dispute(
519-
agreement.serviceProvider,
519+
wrapper.collectorAgreement.serviceProvider,
520520
_fisherman,
521521
_deposit,
522522
0, // no related dispute,
@@ -528,10 +528,10 @@ contract DisputeManager is
528528

529529
emit IndexingFeeDisputeCreated(
530530
disputeId,
531-
agreement.serviceProvider,
531+
wrapper.collectorAgreement.serviceProvider,
532532
_fisherman,
533533
_deposit,
534-
agreement.payer,
534+
wrapper.collectorAgreement.payer,
535535
_agreementId,
536536
_poi,
537537
_entities,

0 commit comments

Comments
 (0)