Skip to content

Commit 1d2b76d

Browse files
committed
fix: more cleanup on horizon, interfaces and toolshed packages
Signed-off-by: Tomás Migone <[email protected]>
1 parent 28f2661 commit 1d2b76d

File tree

13 files changed

+16
-1137
lines changed

13 files changed

+16
-1137
lines changed

packages/horizon/contracts/staking/HorizonStaking.sol

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
3838
/// @dev Maximum number of simultaneous stake thaw requests (per provision) or undelegations (per delegation)
3939
uint256 private constant MAX_THAW_REQUESTS = 1_000;
4040

41-
/// @dev Address of the staking extension contract
42-
address private immutable STAKING_EXTENSION_ADDRESS;
43-
4441
/// @dev Minimum amount of delegation.
4542
uint256 private constant MIN_DELEGATION = 1e18;
4643

@@ -73,50 +70,12 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
7370
/**
7471
* @notice The staking contract is upgradeable however we still use the constructor to set a few immutable variables
7572
* @param controller The address of the Graph controller contract
76-
* @param stakingExtensionAddress The address of the staking extension contract
7773
* @param subgraphDataServiceAddress The address of the subgraph data service
7874
*/
7975
constructor(
8076
address controller,
81-
address stakingExtensionAddress,
8277
address subgraphDataServiceAddress
83-
) HorizonStakingBase(controller, subgraphDataServiceAddress) {
84-
STAKING_EXTENSION_ADDRESS = stakingExtensionAddress;
85-
}
86-
87-
/**
88-
* @notice Delegates the current call to the StakingExtension implementation.
89-
* @dev This function does not return to its internal call site, it will return directly to the
90-
* external caller.
91-
*/
92-
fallback() external {
93-
// solhint-disable-previous-line payable-fallback, no-complex-fallback
94-
address extensionImpl = STAKING_EXTENSION_ADDRESS;
95-
// solhint-disable-next-line no-inline-assembly
96-
assembly {
97-
// (a) get free memory pointer
98-
let ptr := mload(0x40)
99-
100-
// (1) copy incoming call data
101-
calldatacopy(ptr, 0, calldatasize())
102-
103-
// (2) forward call to logic contract
104-
let result := delegatecall(gas(), extensionImpl, ptr, calldatasize(), 0, 0)
105-
let size := returndatasize()
106-
107-
// (3) retrieve return data
108-
returndatacopy(ptr, 0, size)
109-
110-
// (4) forward return data back to caller
111-
switch result
112-
case 0 {
113-
revert(ptr, size)
114-
}
115-
default {
116-
return(ptr, size)
117-
}
118-
}
119-
}
78+
) HorizonStakingBase(controller, subgraphDataServiceAddress) {}
12079

12180
/*
12281
* STAKING

packages/horizon/contracts/staking/HorizonStakingBase.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ abstract contract HorizonStakingBase is
5252
SUBGRAPH_DATA_SERVICE_ADDRESS = subgraphDataServiceAddress;
5353
}
5454

55+
/// @inheritdoc IHorizonStakingBase
56+
function getSubgraphService() external view override returns (address) {
57+
return SUBGRAPH_DATA_SERVICE_ADDRESS;
58+
}
59+
5560
/// @inheritdoc IHorizonStakingBase
5661
/// @dev Removes deprecated fields from the return value.
5762
function getServiceProvider(address serviceProvider) external view override returns (ServiceProvider memory) {

packages/horizon/ignition/modules/core/HorizonStaking.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import GraphProxyAdminArtifact from '@graphprotocol/contracts/artifacts/contract
33
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'
44

55
import HorizonStakingArtifact from '../../../build/contracts/contracts/staking/HorizonStaking.sol/HorizonStaking.json'
6-
import HorizonStakingExtensionArtifact from '../../../build/contracts/contracts/staking/HorizonStakingExtension.sol/HorizonStakingExtension.json'
7-
import ExponentialRebatesArtifact from '../../../build/contracts/contracts/staking/libraries/ExponentialRebates.sol/ExponentialRebates.json'
86
import GraphPeripheryModule, { MigratePeripheryModule } from '../periphery/periphery'
97
import { upgradeGraphProxy } from '../proxy/GraphProxy'
108
import { deployImplementation } from '../proxy/implementation'
@@ -17,25 +15,11 @@ export default buildModule('HorizonStaking', (m) => {
1715
const subgraphServiceAddress = m.getParameter('subgraphServiceAddress')
1816
const maxThawingPeriod = m.getParameter('maxThawingPeriod')
1917

20-
// Deploy HorizonStakingExtension - requires periphery and proxies to be registered in the controller
21-
const ExponentialRebates = m.library('ExponentialRebates', ExponentialRebatesArtifact)
22-
const HorizonStakingExtension = m.contract(
23-
'HorizonStakingExtension',
24-
HorizonStakingExtensionArtifact,
25-
[Controller, subgraphServiceAddress],
26-
{
27-
libraries: {
28-
ExponentialRebates: ExponentialRebates,
29-
},
30-
after: [GraphPeripheryModule, HorizonProxiesModule],
31-
},
32-
)
33-
3418
// Deploy HorizonStaking implementation
3519
const HorizonStakingImplementation = deployImplementation(m, {
3620
name: 'HorizonStaking',
3721
artifact: HorizonStakingArtifact,
38-
constructorArgs: [Controller, HorizonStakingExtension, subgraphServiceAddress],
22+
constructorArgs: [Controller, subgraphServiceAddress],
3923
})
4024

4125
// Upgrade proxy to implementation contract
@@ -61,24 +45,11 @@ export const MigrateHorizonStakingDeployerModule = buildModule('HorizonStakingDe
6145

6246
const HorizonStakingProxy = m.contractAt('HorizonStakingProxy', GraphProxyArtifact, horizonStakingAddress)
6347

64-
// Deploy HorizonStakingExtension - requires periphery and proxies to be registered in the controller
65-
const ExponentialRebates = m.library('ExponentialRebates', ExponentialRebatesArtifact)
66-
const HorizonStakingExtension = m.contract(
67-
'HorizonStakingExtension',
68-
HorizonStakingExtensionArtifact,
69-
[Controller, subgraphServiceAddress],
70-
{
71-
libraries: {
72-
ExponentialRebates: ExponentialRebates,
73-
},
74-
},
75-
)
76-
7748
// Deploy HorizonStaking implementation
7849
const HorizonStakingImplementation = deployImplementation(m, {
7950
name: 'HorizonStaking',
8051
artifact: HorizonStakingArtifact,
81-
constructorArgs: [Controller, HorizonStakingExtension, subgraphServiceAddress],
52+
constructorArgs: [Controller, subgraphServiceAddress],
8253
})
8354

8455
return { HorizonStakingProxy, HorizonStakingImplementation }

packages/horizon/test/deployment/HorizonStaking.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { loadConfig } from '@graphprotocol/toolshed/hardhat'
2-
import { assert, expect } from 'chai'
2+
import { expect } from 'chai'
33
import hre from 'hardhat'
44

55
import { graphProxyTests } from './lib/GraphProxy.test'
@@ -27,16 +27,6 @@ describe('HorizonStaking', function () {
2727
expect(delegationSlashingEnabled).to.equal(false)
2828
})
2929

30-
testIf(4)('should set a non zero thawing period', async function () {
31-
if (process.env.IGNITION_DEPLOYMENT_TYPE === 'protocol') {
32-
assert.fail('Deployment type "protocol": no historical state available')
33-
}
34-
const thawingPeriod = await HorizonStaking.__DEPRECATED_getThawingPeriod()
35-
expect(thawingPeriod).to.not.equal(0)
36-
})
37-
38-
it.skip('should set the right staking extension address')
39-
4030
testIf(4)('should set the right subgraph data service address', async function () {
4131
const subgraphDataServiceAddress = await HorizonStaking.getSubgraphService()
4232
expect(subgraphDataServiceAddress).to.equal(config.$global.subgraphServiceAddress)

packages/horizon/test/integration/during-transition-period/delegator.test.ts

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

0 commit comments

Comments
 (0)