Skip to content

Commit

Permalink
Remove max batch size
Browse files Browse the repository at this point in the history
  • Loading branch information
Siegrift committed Nov 27, 2023
1 parent 589a5ef commit d951574
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 16 deletions.
5 changes: 0 additions & 5 deletions packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ dashes.

The delay in seconds for the endpoint. The endpoint will only serve data that is older than the delay.

#### `maxBatchSize`

The maximum number of signed data entries that can be inserted in one batch. This is a safety measure to prevent
spamming theAPI with large payloads. The batch is rejected if it contains more entries than this value.

#### `cache` _(optional)_

Configures the cache for the API endpoints.
Expand Down
3 changes: 1 addition & 2 deletions packages/api/config/signed-api.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
"delaySeconds": 15
}
],
"allowedAirnodes": ["0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"],
"maxBatchSize": 10
"allowedAirnodes": ["0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"]
}
9 changes: 2 additions & 7 deletions packages/api/src/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { go, goSync } from '@api3/promise-utils';
import { isEmpty, isNil, omit, size } from 'lodash';
import { isEmpty, isNil, omit } from 'lodash';

import { getConfig } from './config';
import { deriveBeaconId, recoverSignerAddress } from './evm';
Expand All @@ -26,7 +26,7 @@ export const batchInsertData = async (requestBody: unknown): Promise<ApiResponse
}

// Ensure that the batch of signed that comes from a whitelisted Airnode.
const { maxBatchSize, endpoints, allowedAirnodes } = getConfig();
const { endpoints, allowedAirnodes } = getConfig();
if (
allowedAirnodes !== '*' &&
!goValidateSchema.data.every((signedData) => allowedAirnodes.includes(signedData.airnode))
Expand All @@ -38,11 +38,6 @@ export const batchInsertData = async (requestBody: unknown): Promise<ApiResponse
const batchSignedData = goValidateSchema.data;
if (isEmpty(batchSignedData)) return generateErrorResponse(400, 'No signed data to push');

// Check whether the size of batch exceeds a maximum batch size
if (size(batchSignedData) > maxBatchSize) {
return generateErrorResponse(400, `Maximum batch size (${maxBatchSize}) exceeded`);
}

// Check whether any duplications exist
if (!isBatchUnique(batchSignedData)) return generateErrorResponse(400, 'No duplications are allowed');

Expand Down
1 change: 0 additions & 1 deletion packages/api/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export type Cache = z.infer<typeof cacheSchema>;

export const configSchema = z.strictObject({
endpoints: endpointsSchema,
maxBatchSize: z.number().nonnegative().int(),
cache: cacheSchema.optional(),
allowedAirnodes: allowedAirnodesSchema,
});
Expand Down
1 change: 0 additions & 1 deletion packages/e2e/src/signed-api/signed-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
"delaySeconds": 10
}
],
"maxBatchSize": 10,
"allowedAirnodes": ["0xbF3137b0a7574563a23a8fC8badC6537F98197CC"]
}

0 comments on commit d951574

Please sign in to comment.