Skip to content

Fix/execute with retry wrapper exec #479

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

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5215dce
ref: fix error output in local test runner
May 23, 2024
0a1fcea
ref: refactor retry to poll on the execution instead of blocking
May 23, 2024
c4967c8
feat: change default retry count to 1 from 3
May 23, 2024
2204281
ref: remove retry wrapper for high level implementation
May 23, 2024
00ef6bb
feat: add further retry testing
May 23, 2024
6480c22
ref: change property access
May 23, 2024
dcb62c4
Merge branch 'staging/v6' of github.com:LIT-Protocol/js-sdk into fix/…
May 23, 2024
c7eab1e
wip
May 24, 2024
3bb7ec5
ref remove test changes
May 24, 2024
e0a7b3a
dev: add endpoint check for handshake
May 24, 2024
2b9604f
ref: remove RetrTollerance type
May 24, 2024
6d80536
dev: cleanup
May 24, 2024
844c5c1
chore: fmt
May 24, 2024
ee0c29b
ref: revert local-test setup
May 26, 2024
5ec04de
Merge branch 'staging/v6' of github.com:LIT-Protocol/js-sdk into fix/…
May 26, 2024
8945758
chore: fmt
May 28, 2024
ad190c1
ref: remove 500 status code for retry
May 28, 2024
481e179
ref: fix error output in local test runner
May 23, 2024
d7d815c
ref: refactor retry to poll on the execution instead of blocking
May 23, 2024
65e0d8f
feat: change default retry count to 1 from 3
May 23, 2024
6fd3e76
ref: remove retry wrapper for high level implementation
May 23, 2024
2511c46
feat: add further retry testing
May 23, 2024
27971e7
ref: change property access
May 23, 2024
1e2ddc1
wip
May 24, 2024
a6cbdf0
ref remove test changes
May 24, 2024
8af63b0
dev: add endpoint check for handshake
May 24, 2024
22f17ef
ref: remove RetrTollerance type
May 24, 2024
a27e006
dev: cleanup
May 24, 2024
7f77ce6
chore: fmt
May 24, 2024
26c176a
ref: revert local-test setup
May 26, 2024
586c7b8
chore: fmt
May 28, 2024
1716c87
ref: remove 500 status code for retry
May 28, 2024
9328e11
chore(lit-core): Run ESLint Fix and remove unused imports
MaximusHaximus May 31, 2024
f3f510f
chore(misc): Remove unnecessary tests of `executeWithRetry()` -- `ret…
MaximusHaximus May 31, 2024
ead1f91
chore(misc): Run ESLint --fix
MaximusHaximus May 31, 2024
7a82393
chore(misc): TS error resolution
MaximusHaximus May 31, 2024
94ddc0f
feat(misc): Add `fetchWithRetry` file with relevant types and helpers
MaximusHaximus May 31, 2024
7fcd82a
chore(misc): Update sendRequest() to use `fetchWithRetries()`
MaximusHaximus May 31, 2024
c614110
chore: Typo fix in function name & `eslint --fix` on `lit-node-client…
MaximusHaximus May 31, 2024
f168848
chore: Typo fix in function name & `eslint --fix` on `lit-node-client…
MaximusHaximus May 31, 2024
3009942
Merge branch 'fix/execute-with-retry-wrapper-exec' of github.com:LIT-…
Jun 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions local-tests/setup/tinny-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ export const runTestsParallel = async ({
testIndex + 1
}. ${testName} - Failed after ${maxAttempts} attempts (${timeTaken} ms)\x1b[0m`
);
console.error(`\x1b[31m❌Error:\x1b[90m ${error}\x1b[0m`);
return `${testName} (Failed in ${timeTaken} ms) - Error: ${error}`;
console.error(`\x1b[31m❌Error:\x1b[90m ${error.message}\x1b[0m`);
return `${testName} (Failed in ${timeTaken} ms) - Error: ${error.message}\n Stack Tace: ${error.stack}`;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"download": "^8.0.0",
"ethers": "^5.7.1",
"etherscan-api": "^10.2.0",
"fetch-retry": "^6.0.0",
"find-config": "^1.0.0",
"g": "^2.0.1",
"https-browserify": "^1.0.0",
Expand Down
63 changes: 22 additions & 41 deletions packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
StakingStates,
version,
LIT_ENDPOINT,
CAYENNE_URL,
} from '@lit-protocol/constants';
import { LitContracts } from '@lit-protocol/contracts-sdk';
import {
Expand All @@ -34,8 +33,6 @@ import {
} from '@lit-protocol/crypto';
import {
bootstrapLogManager,
executeWithRetry,
getIpAddress,
isBrowser,
isNode,
log,
Expand All @@ -47,6 +44,8 @@ import {
throwError,
} from '@lit-protocol/misc';

import { composeLitUrl } from './endpoint-version';

import type {
AuthSig,
CustomNetwork,
Expand All @@ -65,7 +64,6 @@ import type {
SuccessNodePromises,
SupportedJsonRequests,
} from '@lit-protocol/types';
import { composeLitUrl } from './endpoint-version';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Listener = (...args: any[]) => void;
Expand Down Expand Up @@ -94,7 +92,6 @@ export type LitNodeClientConfigWithDefaults = Required<
| 'checkNodeAttestation'
| 'litNetwork'
| 'minNodeCount'
| 'retryTolerance'
| 'rpcUrl'
>
> &
Expand All @@ -114,11 +111,6 @@ export class LitCore {
litNetwork: 'cayenne', // Default to cayenne network. will be replaced by custom config.
minNodeCount: 2, // Default value, should be replaced
bootstrapUrls: [], // Default value, should be replaced
retryTolerance: {
timeout: 31_000,
maxRetryCount: 3,
interval: 100,
},
rpcUrl: null,
};
connectedNodes = new Set<string>();
Expand Down Expand Up @@ -891,40 +883,29 @@ export class LitCore {
params: HandshakeWithNode,
requestId: string
): Promise<NodeCommandServerKeysResponse> => {
const res = await executeWithRetry<NodeCommandServerKeysResponse>(
async () => {
// -- get properties from params
const { url } = params;

// -- create url with path
const urlWithPath = composeLitUrl({
url,
endpoint: LIT_ENDPOINT.HANDSHAKE,
});
// -- get properties from params
const { url } = params;

log(`handshakeWithNode ${urlWithPath}`);
// -- create url with path
const urlWithPath = composeLitUrl({
url,
endpoint: LIT_ENDPOINT.HANDSHAKE,
});

const data = {
clientPublicKey: 'test',
challenge: params.challenge,
};
log(`handshakeWithNode ${urlWithPath}`);

return await this.sendCommandToNode({
url: urlWithPath,
data,
requestId,
}).catch((err: NodeErrorV3) => {
return err;
});
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(_error: any, _requestId: string, isFinal: boolean) => {
if (!isFinal) {
logError('an error occurred, attempting to retry');
}
},
this.config.retryTolerance
);
const data = {
clientPublicKey: 'test',
challenge: params.challenge,
};

const res = await this.sendCommandToNode({
url: urlWithPath,
data,
requestId,
}).catch((err: NodeErrorV3) => {
return err;
});

return res as NodeCommandServerKeysResponse;
};
Expand Down
Loading