-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Labels
🔌 typescriptTypeScript libraryTypeScript library
Description
If there are closed/terminated wallets in the system, the redemption process takes a long time. This is what happens:
- The
findWalletForRedemptionfunction must iterate over all wallets to check which one can handle the redemption: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/services/redemptions/redemptions-service.ts#L127 - To do the check, the above function must call
walletsto fetch data of the particular wallet: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/ethereum/bridge.ts#L583 - The
walletsfunction callsgetWalletCompressedPublicKeyunder the hood: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/ethereum/bridge.ts#L607 - Closed/terminated wallets are no longer in the contract state so,
getWalletCompressedPublicKeythrows while callinggetWalletPublicKey: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/ethereum/bridge.ts#L521 - The above is not a problem per se as the error is caught. However, the
getWalletPublicKeyuses 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: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/ethereum/wallet-registry.ts#L69
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: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/utils/backoff.ts#L93
Metadata
Metadata
Assignees
Labels
🔌 typescriptTypeScript libraryTypeScript library