Skip to content

Commit

Permalink
fix: rebase and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maikol committed May 22, 2024
1 parent 85a6f9d commit 2fab1d6
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 113 deletions.
5 changes: 1 addition & 4 deletions packages/contracts/contracts/upgrades/GraphProxy.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later

pragma solidity ^0.7.6;

import { Address } from "@openzeppelin/contracts/utils/Address.sol";
pragma solidity >=0.6.12 <0.9.0;

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

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

Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/contracts/upgrades/GraphProxyAdmin.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later

pragma solidity ^0.7.6;
pragma solidity >=0.6.12 <0.9.0;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later

pragma solidity ^0.7.6;
pragma solidity >=0.6.12 <0.9.0;

/**
* @title Graph Proxy Storage
Expand Down
4 changes: 2 additions & 2 deletions packages/horizon/contracts/payments/PaymentsEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ contract PaymentsEscrow is Multicall, GraphDirectory, IPaymentsEscrow {
revert GraphEscrowThawingPeriodTooLong(withdrawEscrowThawingPeriod, MAX_THAWING_PERIOD);
}

revokeCollectorThawingPeriod = revokeCollectorThawingPeriod;
withdrawEscrowThawingPeriod = withdrawEscrowThawingPeriod;
REVOKE_COLLECTOR_THAWING_PERIOD = revokeCollectorThawingPeriod;
WITHDRAW_ESCROW_THAWING_PERIOD = withdrawEscrowThawingPeriod;
}

// approve a data service to collect funds
Expand Down
57 changes: 23 additions & 34 deletions packages/horizon/test/GraphBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pragma solidity ^0.8.24;

import "forge-std/Test.sol";

import { GraphProxyAdmin } from "@graphprotocol/contracts/contracts/upgrades/GraphProxyAdmin.sol";
import { GraphProxy } from "@graphprotocol/contracts/contracts/upgrades/GraphProxy.sol";
import { Controller } from "@graphprotocol/contracts/contracts/governance/Controller.sol";

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

/* Contracts */

GraphProxyAdmin public proxyAdmin;
Controller public controller;
MockGRTToken public token;
GraphPayments public payments;
Expand All @@ -41,6 +44,7 @@ abstract contract GraphBaseTest is Test, Constants {

function setUp() public virtual {
// Deploy ERC20 token
vm.prank(users.deployer);
token = new MockGRTToken();

// Setup Users
Expand Down Expand Up @@ -68,10 +72,13 @@ abstract contract GraphBaseTest is Test, Constants {

function deployProtocolContracts() private {
vm.startPrank(users.governor);
proxyAdmin = new GraphProxyAdmin();
controller = new Controller();
controller.setContractProxy(keccak256("GraphToken"), address(token));
vm.stopPrank();

// Staking Proxy
vm.prank(users.deployer);
GraphProxy stakingProxy = new GraphProxy(address(0), address(proxyAdmin));

// GraphPayments predict address
bytes32 saltPayments = keccak256("GraphPaymentsSalt");
Expand Down Expand Up @@ -101,39 +108,16 @@ abstract contract GraphBaseTest is Test, Constants {
users.deployer
);

// HorizonStakingExtension predict address
bytes32 saltHorizonStakingExtension = keccak256("HorizonStakingExtensionSalt");
bytes32 horizonStakingExtensionHash = keccak256(bytes.concat(
vm.getCode("HorizonStakingExtension.sol:HorizonStakingExtension"),
abi.encode(address(controller), subgraphDataServiceAddress)
));
address predictedAddressHorizonStakingExtension = vm.computeCreate2Address(
saltHorizonStakingExtension,
horizonStakingExtensionHash,
users.deployer
);

// HorizonStaking predict address
bytes32 saltHorizonStaking = keccak256("saltHorizonStaking");
bytes32 horizonStakingHash = keccak256(bytes.concat(
vm.getCode("HorizonStaking.sol:HorizonStaking"),
abi.encode(
address(controller),
predictedAddressHorizonStakingExtension,
subgraphDataServiceAddress
)
));
address predictedAddressHorizonStaking = vm.computeCreate2Address(
saltHorizonStaking,
horizonStakingHash,
users.deployer
);

// Setup controller
vm.startPrank(users.governor);
controller.setContractProxy(keccak256("GraphEscrow"), predictedAddressEscrow);
controller.setContractProxy(keccak256("GraphToken"), address(token));
controller.setContractProxy(keccak256("PaymentsEscrow"), predictedAddressEscrow);
controller.setContractProxy(keccak256("GraphPayments"), predictedPaymentsAddress);
controller.setContractProxy(keccak256("Staking"), address(predictedAddressHorizonStaking));
controller.setContractProxy(keccak256("Staking"), address(stakingProxy));
controller.setContractProxy(keccak256("EpochManager"), makeAddr("EpochManager"));
controller.setContractProxy(keccak256("RewardsManager"), makeAddr("RewardsManager"));
controller.setContractProxy(keccak256("Curation"), makeAddr("Curation"));
controller.setContractProxy(keccak256("GraphTokenGateway"), makeAddr("GraphTokenGateway"));
vm.stopPrank();

vm.startPrank(users.deployer);
Expand All @@ -146,16 +130,21 @@ abstract contract GraphBaseTest is Test, Constants {
revokeCollectorThawingPeriod,
withdrawEscrowThawingPeriod
);
stakingExtension = new HorizonStakingExtension{salt: saltHorizonStakingExtension}(
stakingExtension = new HorizonStakingExtension(
address(controller),
subgraphDataServiceAddress
);
stakingBase = new HorizonStaking{salt: saltHorizonStaking}(
stakingBase = new HorizonStaking(
address(controller),
address(stakingExtension),
subgraphDataServiceAddress
);
staking = IHorizonStaking(address(stakingBase));
vm.stopPrank();

vm.startPrank(users.governor);
proxyAdmin.upgrade(stakingProxy, address(stakingBase));
proxyAdmin.acceptProxy(stakingBase, stakingProxy);
staking = IHorizonStaking(address(stakingProxy));
vm.stopPrank();
}

Expand Down
33 changes: 0 additions & 33 deletions packages/horizon/test/HorizonStaking.t.sol

This file was deleted.

38 changes: 0 additions & 38 deletions packages/horizon/test/HorizonStaking.ts

This file was deleted.

0 comments on commit 2fab1d6

Please sign in to comment.