Skip to content

Commit 2fab1d6

Browse files
committed
fix: rebase and fixes
1 parent 85a6f9d commit 2fab1d6

File tree

7 files changed

+28
-113
lines changed

7 files changed

+28
-113
lines changed

packages/contracts/contracts/upgrades/GraphProxy.sol

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity ^0.7.6;
4-
5-
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
3+
pragma solidity >=0.6.12 <0.9.0;
64

75
import { GraphProxyStorage } from "./GraphProxyStorage.sol";
86

@@ -160,7 +158,6 @@ contract GraphProxy is GraphProxyStorage, IGraphProxy {
160158
*/
161159
function _acceptUpgrade() internal {
162160
address _pendingImplementation = _getPendingImplementation();
163-
require(Address.isContract(_pendingImplementation), "Impl must be a contract");
164161
require(_pendingImplementation != address(0), "Impl cannot be zero address");
165162
require(msg.sender == _pendingImplementation, "Only pending implementation");
166163

packages/contracts/contracts/upgrades/GraphProxyAdmin.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity ^0.7.6;
3+
pragma solidity >=0.6.12 <0.9.0;
44

55
import { Governed } from "../governance/Governed.sol";
66

packages/contracts/contracts/upgrades/GraphProxyStorage.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity ^0.7.6;
3+
pragma solidity >=0.6.12 <0.9.0;
44

55
/**
66
* @title Graph Proxy Storage

packages/horizon/contracts/payments/PaymentsEscrow.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ contract PaymentsEscrow is Multicall, GraphDirectory, IPaymentsEscrow {
7676
revert GraphEscrowThawingPeriodTooLong(withdrawEscrowThawingPeriod, MAX_THAWING_PERIOD);
7777
}
7878

79-
revokeCollectorThawingPeriod = revokeCollectorThawingPeriod;
80-
withdrawEscrowThawingPeriod = withdrawEscrowThawingPeriod;
79+
REVOKE_COLLECTOR_THAWING_PERIOD = revokeCollectorThawingPeriod;
80+
WITHDRAW_ESCROW_THAWING_PERIOD = withdrawEscrowThawingPeriod;
8181
}
8282

8383
// approve a data service to collect funds

packages/horizon/test/GraphBase.t.sol

+23-34
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ pragma solidity ^0.8.24;
33

44
import "forge-std/Test.sol";
55

6+
import { GraphProxyAdmin } from "@graphprotocol/contracts/contracts/upgrades/GraphProxyAdmin.sol";
7+
import { GraphProxy } from "@graphprotocol/contracts/contracts/upgrades/GraphProxy.sol";
68
import { Controller } from "@graphprotocol/contracts/contracts/governance/Controller.sol";
79

810
import { PaymentsEscrow } from "contracts/payments/PaymentsEscrow.sol";
@@ -18,6 +20,7 @@ abstract contract GraphBaseTest is Test, Constants {
1820

1921
/* Contracts */
2022

23+
GraphProxyAdmin public proxyAdmin;
2124
Controller public controller;
2225
MockGRTToken public token;
2326
GraphPayments public payments;
@@ -41,6 +44,7 @@ abstract contract GraphBaseTest is Test, Constants {
4144

4245
function setUp() public virtual {
4346
// Deploy ERC20 token
47+
vm.prank(users.deployer);
4448
token = new MockGRTToken();
4549

4650
// Setup Users
@@ -68,10 +72,13 @@ abstract contract GraphBaseTest is Test, Constants {
6872

6973
function deployProtocolContracts() private {
7074
vm.startPrank(users.governor);
75+
proxyAdmin = new GraphProxyAdmin();
7176
controller = new Controller();
72-
controller.setContractProxy(keccak256("GraphToken"), address(token));
7377
vm.stopPrank();
7478

79+
// Staking Proxy
80+
vm.prank(users.deployer);
81+
GraphProxy stakingProxy = new GraphProxy(address(0), address(proxyAdmin));
7582

7683
// GraphPayments predict address
7784
bytes32 saltPayments = keccak256("GraphPaymentsSalt");
@@ -101,39 +108,16 @@ abstract contract GraphBaseTest is Test, Constants {
101108
users.deployer
102109
);
103110

104-
// HorizonStakingExtension predict address
105-
bytes32 saltHorizonStakingExtension = keccak256("HorizonStakingExtensionSalt");
106-
bytes32 horizonStakingExtensionHash = keccak256(bytes.concat(
107-
vm.getCode("HorizonStakingExtension.sol:HorizonStakingExtension"),
108-
abi.encode(address(controller), subgraphDataServiceAddress)
109-
));
110-
address predictedAddressHorizonStakingExtension = vm.computeCreate2Address(
111-
saltHorizonStakingExtension,
112-
horizonStakingExtensionHash,
113-
users.deployer
114-
);
115-
116-
// HorizonStaking predict address
117-
bytes32 saltHorizonStaking = keccak256("saltHorizonStaking");
118-
bytes32 horizonStakingHash = keccak256(bytes.concat(
119-
vm.getCode("HorizonStaking.sol:HorizonStaking"),
120-
abi.encode(
121-
address(controller),
122-
predictedAddressHorizonStakingExtension,
123-
subgraphDataServiceAddress
124-
)
125-
));
126-
address predictedAddressHorizonStaking = vm.computeCreate2Address(
127-
saltHorizonStaking,
128-
horizonStakingHash,
129-
users.deployer
130-
);
131-
132111
// Setup controller
133112
vm.startPrank(users.governor);
134-
controller.setContractProxy(keccak256("GraphEscrow"), predictedAddressEscrow);
113+
controller.setContractProxy(keccak256("GraphToken"), address(token));
114+
controller.setContractProxy(keccak256("PaymentsEscrow"), predictedAddressEscrow);
135115
controller.setContractProxy(keccak256("GraphPayments"), predictedPaymentsAddress);
136-
controller.setContractProxy(keccak256("Staking"), address(predictedAddressHorizonStaking));
116+
controller.setContractProxy(keccak256("Staking"), address(stakingProxy));
117+
controller.setContractProxy(keccak256("EpochManager"), makeAddr("EpochManager"));
118+
controller.setContractProxy(keccak256("RewardsManager"), makeAddr("RewardsManager"));
119+
controller.setContractProxy(keccak256("Curation"), makeAddr("Curation"));
120+
controller.setContractProxy(keccak256("GraphTokenGateway"), makeAddr("GraphTokenGateway"));
137121
vm.stopPrank();
138122

139123
vm.startPrank(users.deployer);
@@ -146,16 +130,21 @@ abstract contract GraphBaseTest is Test, Constants {
146130
revokeCollectorThawingPeriod,
147131
withdrawEscrowThawingPeriod
148132
);
149-
stakingExtension = new HorizonStakingExtension{salt: saltHorizonStakingExtension}(
133+
stakingExtension = new HorizonStakingExtension(
150134
address(controller),
151135
subgraphDataServiceAddress
152136
);
153-
stakingBase = new HorizonStaking{salt: saltHorizonStaking}(
137+
stakingBase = new HorizonStaking(
154138
address(controller),
155139
address(stakingExtension),
156140
subgraphDataServiceAddress
157141
);
158-
staking = IHorizonStaking(address(stakingBase));
142+
vm.stopPrank();
143+
144+
vm.startPrank(users.governor);
145+
proxyAdmin.upgrade(stakingProxy, address(stakingBase));
146+
proxyAdmin.acceptProxy(stakingBase, stakingProxy);
147+
staking = IHorizonStaking(address(stakingProxy));
159148
vm.stopPrank();
160149
}
161150

packages/horizon/test/HorizonStaking.t.sol

-33
This file was deleted.

packages/horizon/test/HorizonStaking.ts

-38
This file was deleted.

0 commit comments

Comments
 (0)