Open lukasz-zimnoch opened 3 weeks ago
If there are closed/terminated wallets in the system, the redemption process takes a long time. This is what happens:
findWalletForRedemption
wallets
getWalletCompressedPublicKey
getWalletPublicKey
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
backoffRetrier
Wallet with the given ID has not been registered
errorMatcher
Hey @lukasz-zimnoch please review this
If there are closed/terminated wallets in the system, the redemption process takes a long time. This is what happens:
findWalletForRedemption
function 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#L127wallets
to fetch data of the particular wallet: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/ethereum/bridge.ts#L583wallets
function callsgetWalletCompressedPublicKey
under the hood: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/ethereum/bridge.ts#L607getWalletCompressedPublicKey
throws while callinggetWalletPublicKey
: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/ethereum/bridge.ts#L521getWalletPublicKey
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: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/ethereum/wallet-registry.ts#L69The solution is simple. The
backoffRetrier
function should not retry if the contract call reverts withWallet with the given ID has not been registered
error. This can be achieved by passing a customerrorMatcher
argument to this specificbackoffRetrier
call: https://github.com/keep-network/tbtc-v2/blob/51094e4cdaefdf82a11b80f7e9e6899a6333a9ca/typescript/src/lib/utils/backoff.ts#L93