Skip to content

fix: reuse Protocol V2 wallet session in allNetwork get-address - #934

Merged
wabicai merged 4 commits into
onekeyfrom
fix/allnetwork-v2-reuse-wallet-session
Sep 16, 2026
Merged

wabicai merged 4 commits into
onekeyfrom
fix/allnetwork-v2-reuse-wallet-session

Conversation

@wabicai

@wabicai wabicai commented Sep 13, 2026

Copy link
Copy Markdown
Member

Related task: OK-63410

Summary

Speed up Protocol V2 all-network address retrieval by reusing the selected wallet session across nested chain methods and batching silent reads by chain. Recoverable item failures retain the valid results, and individual retries suppress only address notifications already emitted by the initial batch.

Behavior and compatibility

  • Resume the nested wallet once per seed domain, with an additional Cardano-domain resume when needed. Reuse is scoped to one parent request; device commands remain serialized.
  • allNetworkGetAddress (non-loop) returns the full result array. allNetworkGetAddressByLoop emits per-item callbacks and a finish callback. Public parameters, result shape, input result ordering and App API selection remain unchanged.
  • Silent V2 groups can retry individual items after a skippable batch error. A valid / forbidden / valid bundle returns [success, failure, success].
  • Forward address notifications immediately. Count already-emitted notifications within the group so retries do not duplicate them, while intentional repeated input addresses keep their notification count. Other events pass through unchanged.
  • Run V2 groups containing displayed addresses, including unspecified showOnOneKey, individually from the start to prevent repeated confirmations.
  • Cancellation, wallet mismatch and fatal link errors propagate without individual retries.
  • Preserve V1 grouping and error behavior. Shared non-loop progress now counts completed addresses and reaches 100%.
  • Keep the code change in the original three all-network files: isolate group execution and cancellation checks, reuse the generated parameter type, and write results directly into their original array positions.

CLI hardware measurements

Method: macOS Node CLI, Pro2 over USB, Protocol V2, firmware 1.0.1. Compared base 9fe52e6e9f93cfdcfe5ae4800512a2e97b931408 with original PR head 1bdedeb879cb1e658e2375bf55eeb774714c3f88 in the same SDK process, alternating implementations. All requests used showOnOneKey: false; initial connection, unlocking, and wallet selection were excluded. The harness called the actual all-network APIs; the CLI's separate batch-get-address command does not exercise these APIs.

Each row below is the median of 3 runs per implementation. Bundles contain equal numbers of EVM and SOL account paths. “Less time” means (before - after) / before.

Wallet API Addresses Before PR Time saved Less time
Standard non-loop 4 5.57 s 4.44 s 1.13 s 20.2%
Standard non-loop 12 14.23 s 9.87 s 4.35 s 30.6%
Standard non-loop 30 33.02 s 21.92 s 11.10 s 33.6%
Standard loop 4 5.67 s 4.50 s 1.17 s 20.6%
Standard loop 12 14.37 s 9.98 s 4.39 s 30.5%
Standard loop 30 33.13 s 21.97 s 11.16 s 33.7%
Hidden non-loop 12 13.76 s 9.84 s 3.92 s 28.5%
Hidden loop 12 13.50 s 9.82 s 3.68 s 27.2%

All 48 timed calls matched the baseline's ordered results; loop callback order also matched. Hidden-wallet results were distinct from the standard wallet.

Additional single-run comparisons (not medians):

Bundle, non-loop Before PR Time saved Less time
12 different chains, including ADA 19.26 s 15.14 s 4.12 s 21.4%
BTC / SUI / Aptos, 4 paths each 17.54 s 8.06 s 9.47 s 54.0%

For 12 EVM/SOL addresses, total DeviceSessionGet calls fell from 13 to 2 (outer wallet check plus the first nested resume); standard-wallet DeviceStatusGet calls fell from 28 to 6. The 12 address commands remain serialized. For BTC/SUI/Aptos, BatchGetPublickeys additionally fell from 12 to 3.

Measurement boundary: these timings compare the explicitly listed baseline and original PR revisions, before the later error-isolation and notification fixes. The alpha.122 implementation preserves the successful silent batching/session path; 72 simulated V2 differential cases against 680227b20 confirmed unchanged commands and final results, with unchanged notifications on successful calls. The final artifact has not been timed on hardware, so the table is not a fresh alpha.122 benchmark. Error fallback adds work and is outside the timing figures.

Validation and remaining coverage

  • Focused regression: 4 suites, 386 passed / 4 skipped, covering notifications, duplicate inputs, immediate delivery, V1 behavior, V2 session reuse, Cardano domains, wallet mismatch, cancellation and fatal links. The new notification assertions reproduced the defect before the fix.
  • V1 CLI simulation: 432 EVM/SOL cases across Pro, Touch, Classic, Classic 1S, Classic Pure and Mini, with wallet/display/mode/error variations. Commands, final results and non-progress events match onekey baseline db702ae94; only the documented progress correction differs.
  • V2 CLI simulation: 72 EVM/SOL cases against previous PR head 680227b20. Commands, final results, progress and other events match; successful notification order/count match; duplicate notifications from failed silent batches are removed.
  • Commit and PR checks: yarn agent:check --profile commit passed on Node 22.21.1, including Core (88 suites; 1348 passed / 4 skipped) and all affected package tests/builds. Final yarn agent:check --profile pr passed (full lint, tests, build and version checks). GitHub CI passed for source commit 37770cd3a. One existing Electron BLE reacquire test timed out on the first attempt; its focused rerun and the completed full commit check passed without transport changes.
  • Hardware coverage remains the original Pro2 USB measurements above. Final alpha.122 hardware rerun, V1 hardware and BLE are untested. Hidden Cardano remains unverified because the baseline failed in the outer wallet check with code 112 before comparison.

npm release

  • Version: 1.2.2-alpha.122; dist-tag: ok63410.
  • All 32 SDK package versions and existing exact workspace references are aligned. The repository workflow publishes 25 public packages: 24 SDK packages plus hardware-example.
  • Source commit: 37770cd3ae109751f082715228b6155487b7da56.
  • Includes the merged onekey baseline db702ae94 (through docs: align SDK developer guides with current API contracts #941), error isolation and notification fixes. Relative to that baseline, this PR changes the original three all-network files and 36 version manifests.
  • Publication: npm release workflow succeeded. All 25/25 public packages are available from npm; exact versions, ok63410 tags, integrity metadata and gitHead values match the source commit above.
  • Downloaded Core tarball verification passed: SHA-512 integrity, notification fix and type declarations are present; dist/index.js matches the locally validated build byte-for-byte.
  • Install: @onekeyfe/hd-core@1.2.2-alpha.122.
  • Published under the dedicated ok63410 tag. Registry verification confirms latest and next remained unchanged for all 25 packages.

Further optimization

EVM/SOL still pay per-address device processing time, so further gains require firmware batching or fewer requested paths. BTC/SUI/Aptos already benefit from public-key batching. Changing the App's loop mode changes callback behavior and is outside this PR.

@wabicai
wabicai marked this pull request as ready for review September 15, 2026 09:38
@sidmorizon

Copy link
Copy Markdown
Contributor

@codex review

@sidmorizon

Copy link
Copy Markdown
Contributor

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-16T07:09:01.301383Z 37770cd Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sidmorizon

Copy link
Copy Markdown
Contributor

Claude review session: https://claude.ai/code/session_01VBxNAjXsLGp9WWYuFiBSxp

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37770cd3ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/api/allnetwork/AllNetworkGetAddress.ts
Comment thread packages/core/src/api/allnetwork/AllNetworkGetAddress.ts
Comment thread packages/core/src/api/allnetwork/AllNetworkGetAddress.ts
@wabicai
wabicai merged commit fbbe379 into onekey Sep 16, 2026
14 checks passed
@wabicai
wabicai deleted the fix/allnetwork-v2-reuse-wallet-session branch September 16, 2026 12:10
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.

3 participants