Skip to content

chore: parallellize keychain and queryPromise #6136

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

Merged
merged 1 commit into from
May 30, 2025
Merged

Conversation

Gautam2305
Copy link
Contributor

@Gautam2305 Gautam2305 commented May 16, 2025

Ticket: CAAS-7

  • parallellize keychain and queryPromise in prebuildAndSignTransaction function to improve /sendcoins endpoint performance

@Gautam2305 Gautam2305 force-pushed the CAAS-7-round-trips branch 2 times, most recently from e0befb2 to 7baae82 Compare May 16, 2025 11:06
@Gautam2305 Gautam2305 force-pushed the CAAS-7-round-trips branch 2 times, most recently from 8ecb7ea to bbb3faa Compare May 20, 2025 07:40
@Gautam2305 Gautam2305 force-pushed the CAAS-7-round-trips branch from c682e7c to 2ba5ea3 Compare May 20, 2025 09:00
@Gautam2305 Gautam2305 force-pushed the CAAS-7-round-trips branch from 87c70b9 to c829563 Compare May 20, 2025 10:02
@Gautam2305 Gautam2305 marked this pull request as ready for review May 20, 2025 10:34
@Gautam2305 Gautam2305 requested review from a team as code owners May 20, 2025 10:34
@Gautam2305 Gautam2305 force-pushed the CAAS-7-round-trips branch from 4bd8ccb to 037ee71 Compare May 20, 2025 11:48
shashankms288
shashankms288 previously approved these changes May 20, 2025
Copy link
Contributor

@shashankms288 shashankms288 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Gautam2305 Gautam2305 dismissed stale reviews from shashankms288 and margueriteblair via cd404c2 May 23, 2025 10:50
@Gautam2305 Gautam2305 force-pushed the CAAS-7-round-trips branch 2 times, most recently from cd6d3e3 to a8c3591 Compare May 23, 2025 11:35
@Gautam2305 Gautam2305 force-pushed the CAAS-7-round-trips branch 2 times, most recently from b3d5358 to 8728b12 Compare May 29, 2025 10:41
zahin-mohammad
zahin-mohammad previously approved these changes May 29, 2025
@Gautam2305 Gautam2305 force-pushed the CAAS-7-round-trips branch from 344b4c7 to 5367fbb Compare May 29, 2025 16:44
@Gautam2305 Gautam2305 merged commit a205275 into master May 30, 2025
19 of 20 checks passed
@ppongbitgo ppongbitgo requested a review from Copilot May 30, 2025 11:12
@ppongbitgo ppongbitgo deleted the CAAS-7-round-trips branch May 30, 2025 11:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the performance of the /sendcoins endpoint by parallellizing the keychain validation and transaction prebuild queries in the prebuildAndSignTransaction function.

  • Parallelizes calls to getKeychainsAndValidatePassphrase and prebuildTransaction.
  • Uses Promise.allSettled to concurrently process asynchronous operations and handle their outcomes.
Comments suppressed due to low confidence (1)

modules/sdk-core/src/bitgo/wallet/wallet.ts:2188

  • [nitpick] The name 'keychainPromise' implies a single keychain, but the returned value is an array of keychains; consider renaming it to 'keychainsPromise' for clarity.
const keychainPromise = this.getKeychainsAndValidatePassphrase({

Comment on lines +2207 to +2220
const results = await Promise.allSettled([keychainPromise, txPrebuildQuery]);

// the prebuild can be overridden by providing an explicit tx
const txPrebuild = (await txPrebuildQuery) as PrebuildTransactionResult;
// Handle keychain promise (index 0)
if (results[0].status === 'fulfilled') {
keychains = results[0].value as Keychain[];
} else {
throw results[0].reason;
}

// Handle txPrebuild promise (index 1)
if (results[1].status === 'fulfilled') {
txPrebuild = results[1].value as PrebuildTransactionResult;
} else {
throw results[1].reason;
Copy link
Preview

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider destructuring the results array into named variables (e.g., [keychainResult, txPrebuildResult]) for improved readability and to prevent potential confusion with index ordering.

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

5 participants