Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indexer-common: allow 0 staked allocations #471

Merged
merged 1 commit into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/errors.md
Expand Up @@ -782,7 +782,7 @@ Failed to allocate: Invalid allocation amount provided.

**Solution**

Allocation amounts must be non-zero, positive numbers. To resolve this issue ensure the corresponding indexer rule and/or action queue item have valid `allocationAmount` values.
Allocation amounts must be non-negative numbers. To resolve this issue ensure the corresponding indexer rule and/or action queue item have `allocationAmount` specified to be greater or equal to 0.

## IE062

Expand Down
18 changes: 0 additions & 18 deletions packages/indexer-common/src/indexer-management/allocations.ts
Expand Up @@ -287,17 +287,6 @@ export class AllocationManager {
)
}

if (amount.eq('0')) {
logger.warn('Cannot allocate zero GRT', {
amount: amount.toString(),
})

throw indexerError(
IndexerErrorCode.IE061,
`Invalid allocation amount provided (${amount.toString()}). Must use nonzero allocation amount`,
)
}

const currentEpoch = await this.contracts.epochManager.currentEpoch()

// Identify how many GRT the indexer has staked
Expand Down Expand Up @@ -839,13 +828,6 @@ export class AllocationManager {
)
}

if (amount.eq('0')) {
logger.warn('Cannot reallocate zero GRT, skipping this allocation', {
amount: amount.toString(),
})
throw indexerError(IndexerErrorCode.IE061, `Cannot reallocate zero GRT`)
}

// Identify how many GRT the indexer has staked
const freeStake = await this.contracts.staking.getIndexerCapacity(this.indexer)

Expand Down
Expand Up @@ -453,16 +453,6 @@ export default {
)
}

if (allocationAmount.eq('0')) {
logger.warn('Cannot allocate zero GRT', {
amount: allocationAmount.toString(),
})
throw indexerError(
IndexerErrorCode.IE061,
`Invalid allocation amount provided (${allocationAmount.toString()}). Must use nonzero allocation amount`,
)
}

try {
const currentEpoch = await contracts.epochManager.currentEpoch()

Expand Down Expand Up @@ -916,13 +906,6 @@ export default {
)
}

if (allocationAmount.eq('0')) {
logger.warn('Cannot reallocate zero GRT, skipping this allocation', {
amount: allocationAmount.toString(),
})
throw indexerError(IndexerErrorCode.IE061, `Cannot reallocate zero GRT`)
}

logger.info(`Reallocate to subgraph deployment`, {
existingAllocationAmount: formatGRT(allocationData.allocatedTokens),
newAllocationAmount: formatGRT(allocationAmount),
Expand Down
6 changes: 3 additions & 3 deletions packages/indexer-common/src/subgraphs.ts
Expand Up @@ -151,7 +151,7 @@ enum ActivationCriteria {
UNSUPPORTED = 'unsupported',
NEVER = 'never',
OFFCHAIN = 'offchain',
ZERO_ALLOCATION_AMOUNT = 'zero_allocation_amount',
INVALID_ALLOCATION_AMOUNT = 'invalid_allocation_amount',
}

interface RuleMatch {
Expand Down Expand Up @@ -210,14 +210,14 @@ export function isDeploymentWorthAllocatingTowards(

// The deployment is not eligible for deployment if it doesn't have an allocation amount
if (!deploymentRule?.allocationAmount) {
logger.debug(`Could not find matching rule with non-zero 'allocationAmount':`, {
logger.debug(`Could not find matching rule with defined 'allocationAmount':`, {
deployment: deployment.id.display,
})
return new AllocationDecision(
deployment.id,
deploymentRule,
false,
ActivationCriteria.ZERO_ALLOCATION_AMOUNT,
ActivationCriteria.INVALID_ALLOCATION_AMOUNT,
)
}

Expand Down