Skip to content
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

Improve wallet lookup during redemptions #815

Open
lukasz-zimnoch opened this issue Jun 7, 2024 · 1 comment · May be fixed by #816
Open

Improve wallet lookup during redemptions #815

lukasz-zimnoch opened this issue Jun 7, 2024 · 1 comment · May be fixed by #816
Labels
🔌 typescript TypeScript library

Comments

@lukasz-zimnoch
Copy link
Member

If there are closed/terminated wallets in the system, the redemption process takes a long time. This is what happens:

  1. The findWalletForRedemption function must iterate over all wallets to check which one can handle the redemption:
  2. To do the check, the above function must call wallets to fetch data of the particular wallet:
    async wallets(walletPublicKeyHash: Hex): Promise<Wallet> {
  3. The wallets function calls getWalletCompressedPublicKey under the hood:
    walletPublicKey: await this.getWalletCompressedPublicKey(ecdsaWalletID),
  4. Closed/terminated wallets are no longer in the contract state so, getWalletCompressedPublicKey throws while calling getWalletPublicKey:
    const uncompressedPublicKey = await walletRegistry.getWalletPublicKey(
  5. The above is not a problem per se as the error is caught. However, the getWalletPublicKey uses a backoff retry mechanism inside so the final throw is made after 3 internal retries which takes time and contributes to the long execution time of the entire process:
    const publicKey = await backoffRetrier<string>(this._totalRetryAttempts)(

The solution is simple. The backoffRetrier function should not retry if the contract call reverts with Wallet with the given ID has not been registered error. This can be achieved by passing a custom errorMatcher argument to this specific backoffRetrier call:

errorMatcher: ErrorMatcherFn = retryAll

@lukasz-zimnoch lukasz-zimnoch added the 🔌 typescript TypeScript library label Jun 7, 2024
@ptdatta ptdatta linked a pull request Jun 24, 2024 that will close this issue
@ptdatta
Copy link
Contributor

ptdatta commented Jun 24, 2024

Hey @lukasz-zimnoch please review this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔌 typescript TypeScript library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants