diff --git a/docs/errors.md b/docs/errors.md index 64b3e4f4c..005240040 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -608,7 +608,7 @@ See also: [#IE041](#ie041). **Summary** -TODO +Failed to collect query fees on chain. **Solution** @@ -618,7 +618,7 @@ TODO **Summary** -TODO +Failed to queue transfers for resolving. **Solution** @@ -628,7 +628,7 @@ TODO **Summary** -TODO +Failed to resolve transfer. **Solution** @@ -638,7 +638,7 @@ TODO **Summary** -TODO +Failed to mark transfer as failed. **Solution** @@ -648,7 +648,7 @@ TODO **Summary** -TODO +Failed to withdraw query fees for allocation. **Solution** @@ -658,8 +658,200 @@ TODO **Summary** +Failed to clean up transfers for allocation. + +**Solution** + +TODO + +## IE050 + +**Summary** + +Transaction reverted due to gas limit being hit. + +**Solution** + +TODO + +## IE051 + +**Summary** + +Transaction reverted for unknown reason. + +**Solution** + TODO +## IE052 + +**Summary** + +Transaction aborted: maximum configured gas price reached. + **Solution** TODO + +## IE053 + +**Summary** + +Failed to queue receipts for collecting. + +**Solution** + +TODO + +## IE054 + +**Summary** + +Failed to collect receipts in exchange for query fee voucher. + +**Solution** + +TODO + +## IE055 + +**Summary** + +Failed to redeem query fee voucher. + +**Solution** + +TODO + +## IE056 + +**Summary** + +Failed to remember allocation for collecting receipts later. + +**Solution** + +TODO + +## IE057 + +**Summary** + +Transaction reverted due to failing assertion in contract. + +**Solution** + +TODO + +## IE058 + +**Summary** + +Transaction failed because nonce has already been used. + +**Solution** + +TODO + +## IE059 + +**Summary** + +Failed to check latest operator ETH balance. + +**Solution** + +TODO + +## IE060 + +**Summary** + +Failed to allocate: subgraph is already allocated to. + +**Solution** + +The Indexer has an active allocation on the subgraph so a new one cannot be created. If you are sure to create a new allocation, either `reallocate` instead or `unallocate` the active allocation before `allocate`. Make sure the existing active allocation is closed and this error should resolve. + +## IE061 + +**Summary** + +Failed to allocate: Invalid allocation amount provided. + +**Solution** + +Indexer have to allocate a nonnegative amount of GRT. (At the moment, 0GRT allocation is not accepted neither). If allocation has been set to an invalid amount, update the amount that is positive, nonzero, and within the indexer free stake, and then this error should resolve. + +## IE062 + +**Summary** + +Did not receive contract receipt. + +**Solution** + +Cannot confirm `allocateFrom`, `closeAllocation`, `closeAndAllocate` transactions. Indexer should check if indexer operator is authorized and if network is not paused. Make sure indexer can make calls to the network contracts and indexer operator is authorized, then this error should resolve. + +## IE063 + +**Summary** + +Failed to unallocate: No active allocation with provided id found. + +**Solution** + +The Indexer must have an active allocation on the subgraph before the indexer can unallocate. Make sure the correct allocation id is provided and the error should resolve. + +## IE064 + +**Summary** + +Failed to unallocate: Allocations cannot be closed during this epoch as it was created in this epoch. + +**Solution** + +Allocations cannot be closed within the same epoch that it was created in. Wait until the next epoch and this error should resolve automatically. + +## IE065 + +**Summary** + +Failed to unallocate: Allocation has already been closed. + +**Solution** + +Check the allocation ID and network sync status. If the allocation ID is correct and allocation is closed, then there's nothing to be done. + +## IE066 + +**Summary** + +Allocation not created: Allocation ID already exist. + +**Solution** + +Cannot create a new allocation. The created allocation ID already exist on-chain. Check the network sync status, if status is caught up and an allocation still needs to be opened, agent will create a new unique allocation ID and try again. + +## IE067 + +**Summary** + +Failed to resolve POI: POI not available for deployment at current epoch start block. + +**Solution** + +Check sync and health status of the subgraph to access the issue. Might need to wait index node the sync up and is able to generate the current epoch start block POI. + +## IE068 + +**Summary** + +Failed to resolve POI: User provided POI does not match reference fetched from the graph-node. + +**Solution** + +Check sync and health status of the subgraph to access the issue. If needed, provide a POI or use `--force` to bypass POI checks. + + diff --git a/packages/indexer-common/src/errors.ts b/packages/indexer-common/src/errors.ts index b86faa678..d1101d500 100644 --- a/packages/indexer-common/src/errors.ts +++ b/packages/indexer-common/src/errors.ts @@ -70,6 +70,15 @@ export enum IndexerErrorCode { IE057 = 'IE057', IE058 = 'IE058', IE059 = 'IE059', + IE060 = 'IE060', + IE061 = 'IE061', + IE062 = 'IE062', + IE063 = 'IE063', + IE064 = 'IE064', + IE065 = 'IE065', + IE066 = 'IE066', + IE067 = 'IE067', + IE068 = 'IE068', } export const INDEXER_ERROR_MESSAGES: Record = { @@ -132,6 +141,15 @@ export const INDEXER_ERROR_MESSAGES: Record = { IE057: 'Transaction reverted due to failing assertion in contract', IE058: 'Transaction failed because nonce has already been used', IE059: 'Failed to check latest operator ETH balance', + IE060: 'Failed to allocate: Already allocating to the subgraph deployment', + IE061: 'Failed to allocate: Invalid allocation amount provided.', + IE062: 'Did not receive tx receipt, not authorized or network paused.', + IE063: 'No active allocation with provided id found.', + IE064: 'Failed to unallocate: Allocations cannot be closed in this epoch.', + IE065: 'Failed to unallocate: Allocation has already been closed.', + IE066: 'Failed to allocate: allocation ID already exist on chain', + IE067: 'Failed to query POI for current epoch start block', + IE068: 'User-provided POI did not match with reference POI from graph-node.', } export type IndexerErrorCause = unknown diff --git a/packages/indexer-common/src/indexer-management/allocations.ts b/packages/indexer-common/src/indexer-management/allocations.ts index 3c95cf11b..561688421 100644 --- a/packages/indexer-common/src/indexer-management/allocations.ts +++ b/packages/indexer-common/src/indexer-management/allocations.ts @@ -15,6 +15,7 @@ import { CloseAllocationResult, CreateAllocationResult, fetchIndexingRules, + IndexerError, indexerError, IndexerErrorCode, IndexerManagementModels, @@ -140,7 +141,10 @@ export class AllocationManager { return { actionID: action.id, transactionID: undefined, - failureReason: error.message, + failureReason: + error instanceof IndexerError + ? error.code + : 'Failed to confirm transactions', } } }, @@ -235,10 +239,11 @@ export class AllocationManager { ) } } catch (error) { - logger.error(`'Failed to prepare tx call data: ${error}`) + logger.error(`Failed to prepare tx call data: ${error}`) return { actionID: action.id, - failureReason: error.message, + failureReason: + error instanceof IndexerError ? error.code : `Failed to prepare tx call data`, } } } @@ -266,7 +271,8 @@ export class AllocationManager { deployment: allocation.subgraphDeployment.id.ipfsHash, activeAllocation: allocation.id, }) - throw new Error( + throw indexerError( + IndexerErrorCode.IE060, `Allocation failed. An active allocation already exists for deployment '${allocation.subgraphDeployment.id.ipfsHash}'`, ) } @@ -275,7 +281,8 @@ export class AllocationManager { logger.warn('Cannot allocate a negative amount of GRT', { amount: amount.toString(), }) - throw new Error( + throw indexerError( + IndexerErrorCode.IE061, `Invalid allocation amount provided (${amount.toString()}). Must use positive allocation amount`, ) } @@ -284,7 +291,9 @@ export class AllocationManager { logger.warn('Cannot allocate zero GRT', { amount: amount.toString(), }) - throw new Error( + + throw indexerError( + IndexerErrorCode.IE061, `Invalid allocation amount provided (${amount.toString()}). Must use nonzero allocation amount`, ) } @@ -305,13 +314,11 @@ export class AllocationManager { ) throw indexerError( IndexerErrorCode.IE013, - new Error( - `Allocation of ${formatGRT( - amount, - )} GRT cancelled: indexer only has a free stake amount of ${formatGRT( - freeStake, - )} GRT`, - ), + `Allocation of ${formatGRT( + amount, + )} GRT cancelled: indexer only has a free stake amount of ${formatGRT( + freeStake, + )} GRT`, ) } @@ -348,7 +355,10 @@ export class AllocationManager { allocation: allocationId, state, }) - throw new Error(`Allocation '${allocationId}' already exists onchain`) + throw indexerError( + IndexerErrorCode.IE066, + `Allocation '${allocationId}' already exists onchain`, + ) } logger.debug('Generating new allocation ID proof', { @@ -383,7 +393,8 @@ export class AllocationManager { const subgraphDeployment = new SubgraphDeploymentID(deployment) logger.info(`Confirming 'allocateFrom' transaction`) if (receipt === 'paused' || receipt === 'unauthorized') { - throw new Error( + throw indexerError( + IndexerErrorCode.IE062, `Allocation not created. ${ receipt === 'paused' ? 'Network paused' : 'Operator not authorized' }`, @@ -399,7 +410,7 @@ export class AllocationManager { ) if (!createAllocationEventLogs) { - throw indexerError(IndexerErrorCode.IE014, new Error(`Allocation was never mined`)) + throw indexerError(IndexerErrorCode.IE014, `Allocation was never mined`) } logger.info(`Successfully allocated to subgraph deployment`, { @@ -540,15 +551,17 @@ export class AllocationManager { logger.warn('Allocation does not exist', { allocationID, }) - throw new Error( - `Unallocate failed. An active allocation does not exist with id = '${allocationID}'`, + throw indexerError( + IndexerErrorCode.IE063, + `Unallocate failed: No active allocation with id '${allocationID}' found`, ) } // Ensure allocation is old enough to close const currentEpoch = await this.contracts.epochManager.currentEpoch() if (BigNumber.from(allocation.createdAtEpoch).eq(currentEpoch)) { - throw new Error( + throw indexerError( + IndexerErrorCode.IE064, `Allocation '${allocation.id}' cannot be closed until epoch ${currentEpoch.add( 1, )}. (Allocations cannot be closed in the same epoch they were created)`, @@ -566,7 +579,7 @@ export class AllocationManager { // in the contracts. const state = await this.contracts.staking.getAllocationState(allocation.id) if (state !== 1) { - throw new Error('Allocation has already been closed') + throw indexerError(IndexerErrorCode.IE065) } return { @@ -585,7 +598,10 @@ export class AllocationManager { logger.info(`Confirming 'closeAllocation' transaction`) if (receipt === 'paused' || receipt === 'unauthorized') { - throw new Error(`Allocation '${allocationID}' could not be closed: ${receipt}`) + throw indexerError( + IndexerErrorCode.IE062, + `Allocation '${allocationID}' could not be closed: ${receipt}`, + ) } const closeAllocationEventLogs = this.findEvent( @@ -599,7 +615,7 @@ export class AllocationManager { if (!closeAllocationEventLogs) { throw indexerError( IndexerErrorCode.IE015, - new Error(`Allocation close transaction was never successfully mined`), + `Allocation close transaction was never successfully mined`, ) } @@ -640,7 +656,8 @@ export class AllocationManager { const allocation = await this.networkMonitor.allocation(allocationID) if (!allocation) { - throw new Error( + throw indexerError( + IndexerErrorCode.IE063, `Unallocate failed: No active allocation with id '${allocationID}' found`, ) } @@ -718,8 +735,9 @@ export class AllocationManager { this.logger.warn('Allocation does not exist', { allocationID, }) - throw new Error( - `Unallocate failed. An active allocation does not exist with id = '${allocationID}'`, + throw indexerError( + IndexerErrorCode.IE063, + `Unallocate failed. No active allocation with id '${allocationID}' found`, ) } @@ -774,7 +792,8 @@ export class AllocationManager { if (!allocation) { logger.error(`No existing allocation`) - throw new Error( + throw indexerError( + IndexerErrorCode.IE063, `Reallocation failed: No active allocation with id '${allocationID}' found`, ) } @@ -782,7 +801,8 @@ export class AllocationManager { // Ensure allocation is old enough to close const currentEpoch = await this.contracts.epochManager.currentEpoch() if (BigNumber.from(allocation.createdAtEpoch).eq(currentEpoch)) { - throw new Error( + throw indexerError( + IndexerErrorCode.IE064, `Allocation '${allocation.id}' cannot be closed until epoch ${currentEpoch.add( 1, )}. (Allocations cannot be closed in the same epoch they were created)`, @@ -806,21 +826,24 @@ export class AllocationManager { const state = await this.contracts.staking.getAllocationState(allocation.id) if (state !== 1) { logger.warn(`Allocation has already been closed`) - throw new Error(`Allocation has already been closed`) + throw indexerError(IndexerErrorCode.IE065, `Allocation has already been closed`) } if (amount.lt('0')) { logger.warn('Cannot reallocate a negative amount of GRT', { amount: amount.toString(), }) - throw new Error('Cannot reallocate a negative amount of GRT') + throw indexerError( + IndexerErrorCode.IE061, + 'Cannot reallocate a negative amount of GRT', + ) } if (amount.eq('0')) { logger.warn('Cannot reallocate zero GRT, skipping this allocation', { amount: amount.toString(), }) - throw new Error(`Cannot reallocate zero GRT`) + throw indexerError(IndexerErrorCode.IE061, `Cannot reallocate zero GRT`) } // Identify how many GRT the indexer has staked @@ -834,15 +857,13 @@ export class AllocationManager { if (postCloseFreeStake.lt(amount)) { throw indexerError( IndexerErrorCode.IE013, - new Error( - `Unable to allocate ${formatGRT( - amount, - )} GRT: indexer only has a free stake amount of ${formatGRT( - freeStake, - )} GRT, plus ${formatGRT( - allocation.allocatedTokens, - )} GRT from the existing allocation`, - ), + `Unable to allocate ${formatGRT( + amount, + )} GRT: indexer only has a free stake amount of ${formatGRT( + freeStake, + )} GRT, plus ${formatGRT( + allocation.allocatedTokens, + )} GRT from the existing allocation`, ) } @@ -875,7 +896,7 @@ export class AllocationManager { allocation: newAllocationId, newAllocationState, }) - throw new Error('AllocationID already exists') + throw indexerError(IndexerErrorCode.IE066, 'AllocationID already exists') } logger.debug('Generating new allocation ID proof', { @@ -922,7 +943,10 @@ export class AllocationManager { allocationID, }) if (receipt === 'paused' || receipt === 'unauthorized') { - throw new Error(`Allocation '${allocationID}' could not be closed: ${receipt}`) + throw indexerError( + IndexerErrorCode.IE062, + `Allocation '${allocationID}' could not be closed: ${receipt}`, + ) } const closeAllocationEventLogs = this.findEvent( @@ -936,7 +960,7 @@ export class AllocationManager { if (!closeAllocationEventLogs) { throw indexerError( IndexerErrorCode.IE015, - new Error(`Allocation close transaction was never successfully mined`), + `Allocation close transaction was never successfully mined`, ) } @@ -951,7 +975,7 @@ export class AllocationManager { if (!createAllocationEventLogs) { throw indexerError( IndexerErrorCode.IE014, - new Error(`Allocation create transaction was never mined`), + `Allocation create transaction was never mined`, ) } @@ -994,7 +1018,8 @@ export class AllocationManager { const allocation = await this.networkMonitor.allocation(allocationID) if (!allocation) { - throw new Error( + throw indexerError( + IndexerErrorCode.IE063, `Reallocation failed: No active allocation found on chain with id '${allocationID}' found`, ) } diff --git a/packages/indexer-common/src/indexer-management/monitor.ts b/packages/indexer-common/src/indexer-management/monitor.ts index ac97e73d6..d51d6462d 100644 --- a/packages/indexer-common/src/indexer-management/monitor.ts +++ b/packages/indexer-common/src/indexer-management/monitor.ts @@ -299,13 +299,14 @@ export class NetworkMonitor { return result.data.indexer.allocations.map(parseGraphQLAllocation) } catch (error) { + const err = indexerError(IndexerErrorCode.IE010, error) this.logger.error( `Failed to query indexer's previously closed allocation for the deployment`, { - error, + err, }, ) - throw error + throw err } } @@ -457,7 +458,7 @@ export class NetworkMonitor { } catch (error) { const err = indexerError(IndexerErrorCode.IE010, error) this.logger.error( - `Failed to query subgraphDeployment with with ipfsHash = ${ipfsHash}`, + `Failed to query subgraphDeployment with ipfsHash = ${ipfsHash}`, { err, }, @@ -511,13 +512,16 @@ export class NetworkMonitor { const deploymentStatus = await this.indexingStatusResolver.indexingStatus([ allocation.subgraphDeployment.id, ]) - throw new Error(`POI not available for deployment at current epoch start block. + throw indexerError( + IndexerErrorCode.IE067, + `POI not available for deployment at current epoch start block. currentEpochStartBlock: ${epochStartBlockNumber} deploymentStatus: ${ deploymentStatus.length > 0 ? JSON.stringify(deploymentStatus) : 'not deployed' - }`) + }`, + ) } else { return poi } @@ -527,9 +531,12 @@ export class NetworkMonitor { } else if (poi !== undefined && generatedPOI == undefined) { return poi } - throw new Error(`User provided POI does not match reference fetched from the graph-node. Use '--force' to bypass this POI accuracy check. + throw indexerError( + IndexerErrorCode.IE068, + `User provided POI does not match reference fetched from the graph-node. Use '--force' to bypass this POI accuracy check. POI: ${poi}, - referencePOI: ${generatedPOI}`) + referencePOI: ${generatedPOI}`, + ) } } } @@ -558,7 +565,10 @@ export class NetworkMonitor { } if (!result.data || result.data.length === 0) { - throw new Error(`No data returned by network subgraph`) + throw indexerError( + IndexerErrorCode.IE007, + `No data returned by network subgraph`, + ) } return result.data.graphNetworks[0].isPaused diff --git a/packages/indexer-common/src/indexer-management/resolvers/allocations.ts b/packages/indexer-common/src/indexer-management/resolvers/allocations.ts index 35b85d6f2..59c23d0b2 100644 --- a/packages/indexer-common/src/indexer-management/resolvers/allocations.ts +++ b/packages/indexer-common/src/indexer-management/resolvers/allocations.ts @@ -332,13 +332,16 @@ async function resolvePOI( const deploymentStatus = await indexingStatusResolver.indexingStatus([ allocation.subgraphDeployment.id, ]) - throw new Error(`POI not available for deployment at current epoch start block. ß - currentEpochStartBlock: ${epochStartBlockNumber} - deploymentStatus: ${ - deploymentStatus.length > 0 - ? JSON.stringify(deploymentStatus) - : 'not deployed' - }`) + throw indexerError( + IndexerErrorCode.IE067, + `POI not available for deployment at current epoch start block. + currentEpochStartBlock: ${epochStartBlockNumber} + deploymentStatus: ${ + deploymentStatus.length > 0 + ? JSON.stringify(deploymentStatus) + : 'not deployed' + }`, + ) } else { return poi } @@ -348,9 +351,12 @@ async function resolvePOI( } else if (poi !== undefined && generatedPOI == undefined) { return poi } - throw new Error(`User provided POI does not match reference fetched from the graph-node. Use '--force' to bypass this POI accuracy check. + throw indexerError( + IndexerErrorCode.IE068, + `User provided POI does not match reference fetched from the graph-node. Use '--force' to bypass this POI accuracy check. POI: ${poi}, - referencePOI: ${generatedPOI}`) + referencePOI: ${generatedPOI}`, + ) } } } @@ -431,7 +437,8 @@ export default { deployment: allocation.subgraphDeployment.id.ipfsHash, activeAllocation: allocation.id, }) - throw new Error( + throw indexerError( + IndexerErrorCode.IE060, `Allocation failed. An active allocation already exists for deployment '${allocation.subgraphDeployment.id.ipfsHash}'`, ) } @@ -440,7 +447,8 @@ export default { logger.warn('Cannot allocate a negative amount of GRT', { amount: formatGRT(allocationAmount), }) - throw new Error( + throw indexerError( + IndexerErrorCode.IE061, `Invalid allocation amount provided (${amount.toString()}). Must use positive allocation amount`, ) } @@ -449,7 +457,8 @@ export default { logger.warn('Cannot allocate zero GRT', { amount: allocationAmount.toString(), }) - throw new Error( + throw indexerError( + IndexerErrorCode.IE061, `Invalid allocation amount provided (${allocationAmount.toString()}). Must use nonzero allocation amount`, ) } @@ -471,13 +480,11 @@ export default { ) throw indexerError( IndexerErrorCode.IE013, - new Error( - `Allocation of ${formatGRT( - allocationAmount, - )} GRT cancelled: indexer only has a free stake amount of ${formatGRT( - freeStake, - )} GRT`, - ), + `Allocation of ${formatGRT( + allocationAmount, + )} GRT cancelled: indexer only has a free stake amount of ${formatGRT( + freeStake, + )} GRT`, ) } @@ -516,7 +523,10 @@ export default { allocation: allocationId, state, }) - throw new Error(`Allocation '${allocationId}' already exists onchain`) + throw indexerError( + IndexerErrorCode.IE066, + `Allocation '${allocationId}' already exists onchain`, + ) } logger.debug('Generating new allocation ID proof', { @@ -563,7 +573,8 @@ export default { ) if (receipt === 'paused' || receipt === 'unauthorized') { - throw new Error( + throw indexerError( + IndexerErrorCode.IE062, `Allocation not created. ${ receipt === 'paused' ? 'Network paused' : 'Operator not authorized' }`, @@ -579,10 +590,7 @@ export default { ), ) if (!event) { - throw indexerError( - IndexerErrorCode.IE014, - new Error(`Allocation was never mined`), - ) + throw indexerError(IndexerErrorCode.IE014, `Allocation was never mined`) } const createEvent = contracts.staking.interface.decodeEventLog( @@ -665,7 +673,8 @@ export default { // Ensure allocation is old enough to close const currentEpoch = await contracts.epochManager.currentEpoch() if (BigNumber.from(allocationData.createdAtEpoch).eq(currentEpoch)) { - throw new Error( + throw indexerError( + IndexerErrorCode.IE064, `Allocation '${ allocationData.id }' cannot be closed until epoch ${currentEpoch.add( @@ -692,7 +701,7 @@ export default { // in the contracts. const state = await contracts.staking.getAllocationState(allocationData.id) if (state !== 1) { - throw new Error('Allocation has already been closed') + throw indexerError(IndexerErrorCode.IE065, 'Allocation has already been closed') } logger.debug('Sending closeAllocation transaction') @@ -708,7 +717,8 @@ export default { ) if (receipt === 'paused' || receipt === 'unauthorized') { - throw new Error( + throw indexerError( + IndexerErrorCode.IE062, `Allocation '${allocationData.id}' could not be closed: ${receipt}`, ) } @@ -725,7 +735,7 @@ export default { if (!closeEvent) { throw indexerError( IndexerErrorCode.IE014, - new Error(`Allocation close transaction was never successfully mined`), + `Allocation close transaction was never successfully mined`, ) } const closeAllocationEventLogs = contracts.staking.interface.decodeEventLog( @@ -849,8 +859,8 @@ export default { }) if (!allocationData) { - logger.error(`No existing `) - throw new Error( + throw indexerError( + IndexerErrorCode.IE063, `Reallocation failed: No active allocation with id '${allocation}' found`, ) } @@ -859,7 +869,8 @@ export default { // Ensure allocation is old enough to close const currentEpoch = await contracts.epochManager.currentEpoch() if (BigNumber.from(allocationData.createdAtEpoch).eq(currentEpoch)) { - throw new Error( + throw indexerError( + IndexerErrorCode.IE064, `Allocation '${ allocationData.id }' cannot be closed until epoch ${currentEpoch.add( @@ -892,21 +903,24 @@ export default { const state = await contracts.staking.getAllocationState(allocationData.id) if (state !== 1) { logger.warn(`Allocation has already been closed`) - throw new Error(`Allocation has already been closed`) + throw indexerError(IndexerErrorCode.IE065, `Allocation has already been closed`) } if (allocationAmount.lt('0')) { logger.warn('Cannot reallocate a negative amount of GRT', { amount: allocationAmount.toString(), }) - throw new Error('Cannot reallocate a negative amount of GRT') + throw indexerError( + IndexerErrorCode.IE061, + 'Cannot reallocate a negative amount of GRT', + ) } if (allocationAmount.eq('0')) { logger.warn('Cannot reallocate zero GRT, skipping this allocation', { amount: allocationAmount.toString(), }) - throw new Error(`Cannot reallocate zero GRT`) + throw indexerError(IndexerErrorCode.IE061, `Cannot reallocate zero GRT`) } logger.info(`Reallocate to subgraph deployment`, { @@ -926,15 +940,13 @@ export default { if (postCloseFreeStake.lt(allocationAmount)) { throw indexerError( IndexerErrorCode.IE013, - new Error( - `Unable to allocate ${formatGRT( - allocationAmount, - )} GRT: indexer only has a free stake amount of ${formatGRT( - freeStake, - )} GRT, plus ${formatGRT( - allocationData.allocatedTokens, - )} GRT from the existing allocation`, - ), + `Unable to allocate ${formatGRT( + allocationAmount, + )} GRT: indexer only has a free stake amount of ${formatGRT( + freeStake, + )} GRT, plus ${formatGRT( + allocationData.allocatedTokens, + )} GRT from the existing allocation`, ) } @@ -967,7 +979,7 @@ export default { allocation: newAllocationId, newAllocationState, }) - throw new Error('AllocationID already exists') + throw indexerError(IndexerErrorCode.IE066, 'AllocationID already exists') } logger.debug('Generating new allocation ID proof', { @@ -1020,7 +1032,10 @@ export default { ) if (receipt === 'paused' || receipt === 'unauthorized') { - throw new Error(`Allocation '${newAllocationId}' could not be closed: ${receipt}`) + throw indexerError( + IndexerErrorCode.IE062, + `Allocation '${newAllocationId}' could not be closed: ${receipt}`, + ) } const events = receipt.events || receipt.logs @@ -1032,10 +1047,7 @@ export default { ), ) if (!createEvent) { - throw indexerError( - IndexerErrorCode.IE014, - new Error(`Allocation was never mined`), - ) + throw indexerError(IndexerErrorCode.IE014, `Allocation was never mined`) } const createAllocationEventLogs = contracts.staking.interface.decodeEventLog( @@ -1054,7 +1066,7 @@ export default { if (!closeEvent) { throw indexerError( IndexerErrorCode.IE014, - new Error(`Allocation close transaction was never successfully mined`), + `Allocation close transaction was never successfully mined`, ) } const closeAllocationEventLogs = contracts.staking.interface.decodeEventLog(