Skip to content

Commit

Permalink
common: Reduce stringency of action validation when adding to queue
Browse files Browse the repository at this point in the history
- Specifically: remove the check that the deployment is published to the
network to avoid race conditions waiting for the network subgraph to
update
  • Loading branch information
fordN committed Dec 12, 2023
1 parent 0c995ad commit 1b78523
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 35 deletions.
4 changes: 3 additions & 1 deletion packages/indexer-common/src/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NetworkMonitor } from './indexer-management'
import { AllocationStatus } from './allocations'
import { Logger } from '@graphprotocol/common-ts'
import { WhereOperators, WhereOptions } from 'sequelize'
import { Op } from 'sequelize'
import { WhereAttributeHashValue } from 'sequelize/types/model'
Expand Down Expand Up @@ -81,6 +82,7 @@ export const isValidActionInput = (
export const validateActionInputs = async (
actions: ActionInput[],
networkMonitor: NetworkMonitor,
logger: Logger,
): Promise<void> => {
// Validate actions before adding to queue
// TODO: Perform all checks simultaneously and throw combined error if 1 or more fail
Expand Down Expand Up @@ -125,7 +127,7 @@ export const validateActionInputs = async (
action.deploymentID,
)
if (!subgraphDeployment) {
throw new Error(
logger.warn(
`No subgraphDeployment with ipfsHash = '${action.deploymentID}' found on the network`,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ import {
import { CombinedError } from '@urql/core'
import { GraphQLError } from 'graphql'
import {
allocateToNotPublishedDeployment,
createTestManagementClient,
invalidReallocateAction,
invalidUnallocateAction,
queuedAllocateAction,
subgraphDeployment1,
subgraphDeployment2,
subgraphDeployment3,
notPublishedSubgraphDeployment,
} from '../util'

const QUEUE_ACTIONS_MUTATION = gql`
Expand Down Expand Up @@ -632,23 +630,6 @@ describe('Actions', () => {
).resolves.toHaveProperty('data.actions', [expectedUpdated])
})

test('Reject action with deployment not on network', async () => {
const inputActions = [allocateToNotPublishedDeployment]

await expect(
client.mutation(QUEUE_ACTIONS_MUTATION, { actions: inputActions }).toPromise(),
).resolves.toHaveProperty(
'error',
new CombinedError({
graphQLErrors: [
new GraphQLError(
`No subgraphDeployment with ipfsHash = '${notPublishedSubgraphDeployment}' found on the network`,
),
],
}),
)
})

test('Reject unallocate action with inactive allocationID', async () => {
// This allocation has been closed on chain
const closedAllocation = '0x0001572b5fde192fc1c65630fabb5e13d3ad173e'
Expand Down
14 changes: 0 additions & 14 deletions packages/indexer-common/src/indexer-management/__tests__/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ export const defaults: IndexerManagementDefaults = {
export const subgraphDeployment1 = 'Qmew9PZUJCoDzXqqU6vGyTENTKHrrN4dy5h94kertfudqy'
export const subgraphDeployment2 = 'QmWq1pmnhEvx25qxpYYj9Yp6E1xMKMVoUjXVQBxUJmreSe'
export const subgraphDeployment3 = 'QmRhH2nhNibDVPZmYqq3TUZZARZ77vgjYCvPNiGBCogtgM'
export const notPublishedSubgraphDeployment =
'QmeqJ6hsdyk9dVbo1tvRgAxWrVS3rkERiEMsxzPShKLco6'

export const queuedAllocateAction = {
status: ActionStatus.QUEUED,
Expand All @@ -147,18 +145,6 @@ export const queuedAllocateAction = {
protocolNetwork: 'goerli',
} as ActionInput

export const allocateToNotPublishedDeployment = {
status: ActionStatus.QUEUED,
type: ActionType.ALLOCATE,
deploymentID: notPublishedSubgraphDeployment,
amount: '10000',
force: false,
source: 'indexerAgent',
reason: 'indexingRule',
priority: 0,
protocolNetwork: 'goerli',
} as ActionInput

export const invalidUnallocateAction = {
status: ActionStatus.QUEUED,
type: ActionType.UNALLOCATE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default {
await multiNetworks.mapNetworkMapped(
groupBy(actions, (action) => action.protocolNetwork),
(network: Network, actions: ActionInput[]) =>
validateActionInputs(actions, network.networkMonitor),
validateActionInputs(actions, network.networkMonitor, logger),
)

const alreadyQueuedActions = await ActionManager.fetchActions(models, {
Expand Down

0 comments on commit 1b78523

Please sign in to comment.