Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix(warp): protect against invalid evaluation options
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Feb 26, 2024
1 parent ea8d580 commit f8eec88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/api/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,16 @@ async function readThroughToContractState(
}

// use the combined evaluation options
const contract = warp
.contract(contractTxId)
.setEvaluationOptions(evaluationOptions);
const contract = warp.contract(contractTxId).setEvaluationOptions({
...evaluationOptions,
// Temporary fix: protect against setting a maxInteractionEvaluationTimeSeconds that is too large, warp should do this on all evaluation options
// Reference: https://github.com/warp-contracts/warp/issues/509
maxInteractionEvaluationTimeSeconds: Math.min(
Number.MAX_SAFE_INTEGER,
evaluationOptions.maxInteractionEvaluationTimeSeconds ||
DEFAULT_EVALUATION_OPTIONS.maxInteractionEvaluationTimeSeconds,
),
});

// only use batch read if no block height provided (it does not currently support block heights)
const doBatchRead = providedSortKey || providedBlockHeight === undefined;
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const DEFAULT_STATE_EVALUATION_TIMEOUT_MS = process.env
: DEFAULT_REQUEST_TIMEOUT_MS; // 3 min state timeout (should be <= koa request timeout)
export const allowedContractTypes = ['ant'] as const;
export const DEFAULT_PAGES_PER_BATCH = 50; // loads 5k interactions at a time
export const DEFAULT_EVALUATION_OPTIONS: Partial<EvaluationOptions> = {
export const DEFAULT_EVALUATION_OPTIONS: Partial<EvaluationOptions> &
Required<Pick<EvaluationOptions, 'maxInteractionEvaluationTimeSeconds'>> = {
maxInteractionEvaluationTimeSeconds: 3600, // one hour
};

0 comments on commit f8eec88

Please sign in to comment.