Skip to content

Commit ed7ad2b

Browse files
committed
feat: remove allocate function to reduce bytecode, no one is using it on mainnet
1 parent 6ae3b28 commit ed7ad2b

File tree

11 files changed

+48
-47
lines changed

11 files changed

+48
-47
lines changed

cli/commands/contracts/staking.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export const allocate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<v
3636
const staking = cli.contracts.Staking
3737

3838
logger.info(`Allocating ${cliArgs.amount} tokens on ${subgraphDeploymentID}...`)
39-
await sendTransaction(cli.wallet, staking, 'allocate', [
39+
await sendTransaction(cli.wallet, staking, 'allocateFrom', [
40+
cli.walletAddress,
4041
subgraphDeploymentID,
4142
amount,
4243
allocationID,

contracts/staking/IStaking.sol

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,6 @@ interface IStaking is IStakingData {
9494

9595
// -- Channel management and allocations --
9696

97-
function allocate(
98-
bytes32 _subgraphDeploymentID,
99-
uint256 _tokens,
100-
address _allocationID,
101-
bytes32 _metadata,
102-
bytes calldata _proof
103-
) external;
104-
10597
function allocateFrom(
10698
address _indexer,
10799
bytes32 _subgraphDeploymentID,

contracts/staking/Staking.sol

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -859,24 +859,6 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking, Multicall {
859859
return _withdrawDelegated(msg.sender, _indexer, _delegateToIndexer);
860860
}
861861

862-
/**
863-
* @dev Allocate available tokens to a subgraph deployment.
864-
* @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
865-
* @param _tokens Amount of tokens to allocate
866-
* @param _allocationID The allocation identifier
867-
* @param _metadata IPFS hash for additional information about the allocation
868-
* @param _proof A 65-bytes Ethereum signed message of `keccak256(indexerAddress,allocationID)`
869-
*/
870-
function allocate(
871-
bytes32 _subgraphDeploymentID,
872-
uint256 _tokens,
873-
address _allocationID,
874-
bytes32 _metadata,
875-
bytes calldata _proof
876-
) external override notPaused {
877-
_allocate(msg.sender, _subgraphDeploymentID, _tokens, _allocationID, _metadata, _proof);
878-
}
879-
880862
/**
881863
* @dev Allocate available tokens to a subgraph deployment.
882864
* @param _indexer Indexer address to allocate funds from.

test/disputes/poi.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ describe('DisputeManager:POI', async () => {
7979
await staking.connect(indexerAccount.signer).stake(indexerTokens)
8080
await staking
8181
.connect(indexerAccount.signer)
82-
.allocate(
82+
.allocateFrom(
83+
indexerAccount.address,
8384
subgraphDeploymentID,
8485
indexerAllocatedTokens,
8586
allocationID,
@@ -147,7 +148,8 @@ describe('DisputeManager:POI', async () => {
147148
await staking.connect(indexer.signer).stake(indexerTokens)
148149
const tx1 = await staking
149150
.connect(indexer.signer)
150-
.allocate(
151+
.allocateFrom(
152+
indexer.address,
151153
subgraphDeploymentID,
152154
indexerAllocatedTokens,
153155
allocationID,

test/disputes/query.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ describe('DisputeManager:Query', async () => {
113113
await staking.connect(indexerAccount.signer).stake(indexerTokens)
114114
await staking
115115
.connect(indexerAccount.signer)
116-
.allocate(
116+
.allocateFrom(
117+
indexerAccount.address,
117118
dispute.receipt.subgraphDeploymentID,
118119
indexerAllocatedTokens,
119120
allocationID,
@@ -194,7 +195,8 @@ describe('DisputeManager:Query', async () => {
194195
await staking.connect(indexer.signer).stake(indexerTokens)
195196
const tx1 = await staking
196197
.connect(indexer.signer)
197-
.allocate(
198+
.allocateFrom(
199+
indexer.address,
198200
dispute.receipt.subgraphDeploymentID,
199201
indexerAllocatedTokens,
200202
indexer1ChannelKey.address,

test/payments/allocationExchange.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ describe('AllocationExchange', () => {
102102
await staking.connect(indexer.signer).stake(stakeTokens)
103103
await staking
104104
.connect(indexer.signer)
105-
.allocate(
105+
.allocateFrom(
106+
indexer.address,
106107
subgraphDeploymentID,
107108
stakeTokens,
108109
allocationID,

test/payments/withdrawHelper.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ describe('WithdrawHelper', () => {
8686
await staking.connect(indexer.signer).stake(stakeTokens)
8787
await staking
8888
.connect(indexer.signer)
89-
.allocate(
89+
.allocateFrom(
90+
indexer.address,
9091
subgraphDeploymentID,
9192
stakeTokens,
9293
allocationID,

test/rewards/rewards.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ describe('Rewards', () => {
391391
await staking.connect(indexer1.signer).stake(tokensToAllocate)
392392
await staking
393393
.connect(indexer1.signer)
394-
.allocate(
394+
.allocateFrom(
395+
indexer1.address,
395396
subgraphDeploymentID1,
396397
tokensToAllocate,
397398
allocationID,
@@ -428,7 +429,8 @@ describe('Rewards', () => {
428429
await staking.connect(indexer1.signer).stake(tokensToAllocate)
429430
await staking
430431
.connect(indexer1.signer)
431-
.allocate(
432+
.allocateFrom(
433+
indexer1.address,
432434
subgraphDeploymentID1,
433435
tokensToAllocate,
434436
allocationID,
@@ -471,7 +473,8 @@ describe('Rewards', () => {
471473
await staking.connect(indexer1.signer).stake(tokensToAllocate)
472474
await staking
473475
.connect(indexer1.signer)
474-
.allocate(
476+
.allocateFrom(
477+
indexer1.address,
475478
subgraphDeploymentID1,
476479
tokensToAllocate,
477480
allocationID,
@@ -516,7 +519,8 @@ describe('Rewards', () => {
516519
await staking.connect(indexer1.signer).stake(tokensToAllocate)
517520
await staking
518521
.connect(indexer1.signer)
519-
.allocate(
522+
.allocateFrom(
523+
indexer1.address,
520524
subgraphDeploymentID1,
521525
tokensToAllocate,
522526
allocationID,
@@ -558,7 +562,8 @@ describe('Rewards', () => {
558562
// Allocate
559563
await staking
560564
.connect(indexer1.signer)
561-
.allocate(
565+
.allocateFrom(
566+
indexer1.address,
562567
subgraphDeploymentID1,
563568
tokensToAllocate,
564569
allocationID,
@@ -754,7 +759,8 @@ describe('Rewards', () => {
754759
await staking.connect(indexer1.signer).stake(tokensToAllocate)
755760
await staking
756761
.connect(indexer1.signer)
757-
.allocate(
762+
.allocateFrom(
763+
indexer1.address,
758764
subgraphDeploymentID1,
759765
tokensToAllocate,
760766
allocationID,

test/staking/allocation.test.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ describe('Staking:Allocation', () => {
6767
const allocate = async (tokens: BigNumber) => {
6868
return staking
6969
.connect(indexer.signer)
70-
.allocate(
70+
.allocateFrom(
71+
indexer.address,
7172
subgraphDeploymentID,
7273
tokens,
7374
allocationID,
@@ -206,7 +207,14 @@ describe('Staking:Allocation', () => {
206207
it('reject allocate with invalid allocationID', async function () {
207208
const tx = staking
208209
.connect(indexer.signer)
209-
.allocate(subgraphDeploymentID, tokensToAllocate, AddressZero, metadata, randomHexBytes(20))
210+
.allocateFrom(
211+
indexer.address,
212+
subgraphDeploymentID,
213+
tokensToAllocate,
214+
AddressZero,
215+
metadata,
216+
randomHexBytes(20),
217+
)
210218
await expect(tx).revertedWith('!alloc')
211219
})
212220

@@ -273,7 +281,8 @@ describe('Staking:Allocation', () => {
273281
const invalidProof = await channelKey.generateProof(randomHexBytes(20))
274282
const tx = staking
275283
.connect(indexer.signer)
276-
.allocate(
284+
.allocateFrom(
285+
indexer.address,
277286
subgraphDeploymentID,
278287
tokensToAllocate,
279288
indexer.address,
@@ -286,7 +295,8 @@ describe('Staking:Allocation', () => {
286295
it('invalid proof signature format', async function () {
287296
const tx = staking
288297
.connect(indexer.signer)
289-
.allocate(
298+
.allocateFrom(
299+
indexer.address,
290300
subgraphDeploymentID,
291301
tokensToAllocate,
292302
indexer.address,
@@ -631,7 +641,8 @@ describe('Staking:Allocation', () => {
631641
const allocationID2 = channelKey2.address
632642
await staking
633643
.connect(indexer.signer)
634-
.allocate(
644+
.allocateFrom(
645+
indexer.address,
635646
subgraphDeploymentID,
636647
tokensToAllocate,
637648
allocationID2,
@@ -682,7 +693,8 @@ describe('Staking:Allocation', () => {
682693
staking.connect(indexer.signer).populateTransaction.closeAllocation(allocationID, poi),
683694
staking
684695
.connect(indexer.signer)
685-
.populateTransaction.allocate(
696+
.populateTransaction.allocateFrom(
697+
indexer.address,
686698
subgraphDeploymentID,
687699
tokensToAllocate,
688700
newAllocationID,

test/staking/delegation.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ describe('Staking::Delegation', () => {
534534
const setupAllocation = async (tokens: BigNumber) => {
535535
return staking
536536
.connect(indexer.signer)
537-
.allocate(
537+
.allocateFrom(
538+
indexer.address,
538539
subgraphDeploymentID,
539540
tokens,
540541
allocationID,

0 commit comments

Comments
 (0)