Skip to content

Commit

Permalink
Merge pull request #8502 from LedgerHQ/bugfix/LIVE-15039-fix-invalid-…
Browse files Browse the repository at this point in the history
…channel-webhid

🐛 (webhid): Fix invalid channel error when using multiple apps
  • Loading branch information
aussedatlo authored Nov 28, 2024
2 parents ef8080c + e857228 commit 0aa6ec9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-cats-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/hw-transport-webhid": patch
---

Fix invalid channel when using multiple apps
15 changes: 13 additions & 2 deletions libs/ledgerjs/packages/hw-transport-webhid/src/TransportWebHID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,19 @@ export default class TransportWebHID extends Transport {
let acc;

while (!(result = framing.getReducedResult(acc))) {
const buffer = await this.read();
acc = framing.reduceResponse(acc, buffer);
try {
const buffer = await this.read();
acc = framing.reduceResponse(acc, buffer);
} catch (e) {
if (e instanceof TransportError && e.id === "InvalidChannel") {
// this can happen if the device is connected
// on a different channel (like another app)
// in this case we just filter out the event
continue;
}

throw e;
}
}

log("apdu", "<= " + result.toString("hex"));
Expand Down

1 comment on commit 0aa6ec9

@github-actions
Copy link

Choose a reason for hiding this comment

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

[Bot] Testing with 'Nitrogen' ❌ 1 txs ($6.56) ⏲ 70.6s

❌ 1 specs have problems: Tezos

What is the bot and how does it work? Everything is documented here!

❌ 1 mutation errors
necessary accounts resynced in 0.22ms
▬ TezosWallet 3.0.5 on nanoS 2.1.0
→ FROM undefined: 5.28869 XTZ (152ops) (tz1aDK1uFAmnUXZ7KJPEmcCEFeYHiVZ56zVF on 44'/1729'/0'/0') tezbox#0 js:2:tezos:0240051fc51799e60dcc8870415b87fc4fd948e71b23fdc0d9b8ac7438cf7d4708:tezbox
max spendable ~5.28774
★ using mutation 'send unrevealed'
→ TO undefined: 0 XTZ (0ops) (tz1SApkt3kmMaqNE1qtgADc6m3B49HZkFVDA on 44'/1729'/2'/0') tezbox#2 js:2:tezos:029d7bcf10737806147b22ba4578747ce4ac53e26b443c9eb1ac0e4d5bfbb8f67e:tezbox
✔️ transaction 
SEND 2.643872 XTZ
TO tz1SApkt3kmMaqNE1qtgADc6m3B49HZkFVDA
with fees=0.0005
with gasLimit=600
with storageLimit=277
(estimatedFees 0.000563)
STATUS (738ms)
  amount: 2.643872 XTZ
  estimated fees: 0.000563 XTZ
  total spent: 2.644435 XTZ
errors: 
warnings: 
⚠️ Error: device action timeout. Recent events was:
{"text":"Review operation","x":13,"y":17,"w":107,"h":11}
{"text":"Operation (0)","x":26,"y":-1,"w":94,"h":11}
{"text":"Reveal","x":47,"y":10,"w":81,"h":11}
(totally spent 61.1s – ends at 2024-11-28T11:31:09.189Z)
⚠️ 2 spec hints
  • Spec Tezos:
    • mutations should define a test(): send unrevealed, send revealed, send max (non delegating), delegate unrevealed, delegate revealed, undelegate unrevealed, undelegate revealed
    • There are not enough accounts (3) to cover all mutations (7).
      Please increase the account target to at least 8 accounts
Details of the 1 mutations

Spec Tezos (3)

Spec Tezos found 3 Tezos accounts (preload: 228ms). Will use TezosWallet 3.0.5 on nanoS 2.1.0
undefined: 5.28869 XTZ (152ops) (tz1aDK1uFAmnUXZ7KJPEmcCEFeYHiVZ56zVF on 44'/1729'/0'/0') tezbox#0 js:2:tezos:0240051fc51799e60dcc8870415b87fc4fd948e71b23fdc0d9b8ac7438cf7d4708:tezbox
undefined: 0 XTZ (4ops) (tz1he4fPXP3c9fFrztYT3k7KyYuLb28arFNn on 44'/1729'/1'/0') tezbox#1 js:2:tezos:02fe3d777af5380ef0a431c4985772c9669743050cee5feff717c3c3272d7a2810:tezbox
undefined: 0 XTZ (0ops) (tz1SApkt3kmMaqNE1qtgADc6m3B49HZkFVDA on 44'/1729'/2'/0') tezbox#2 js:2:tezos:029d7bcf10737806147b22ba4578747ce4ac53e26b443c9eb1ac0e4d5bfbb8f67e:tezbox
necessary accounts resynced in 0.22ms
▬ TezosWallet 3.0.5 on nanoS 2.1.0
→ FROM undefined: 5.28869 XTZ (152ops) (tz1aDK1uFAmnUXZ7KJPEmcCEFeYHiVZ56zVF on 44'/1729'/0'/0') tezbox#0 js:2:tezos:0240051fc51799e60dcc8870415b87fc4fd948e71b23fdc0d9b8ac7438cf7d4708:tezbox
max spendable ~5.28774
★ using mutation 'send unrevealed'
→ TO undefined: 0 XTZ (0ops) (tz1SApkt3kmMaqNE1qtgADc6m3B49HZkFVDA on 44'/1729'/2'/0') tezbox#2 js:2:tezos:029d7bcf10737806147b22ba4578747ce4ac53e26b443c9eb1ac0e4d5bfbb8f67e:tezbox
✔️ transaction 
SEND 2.643872 XTZ
TO tz1SApkt3kmMaqNE1qtgADc6m3B49HZkFVDA
with fees=0.0005
with gasLimit=600
with storageLimit=277
(estimatedFees 0.000563)
STATUS (738ms)
  amount: 2.643872 XTZ
  estimated fees: 0.000563 XTZ
  total spent: 2.644435 XTZ
errors: 
warnings: 
⚠️ Error: device action timeout. Recent events was:
{"text":"Review operation","x":13,"y":17,"w":107,"h":11}
{"text":"Operation (0)","x":26,"y":-1,"w":94,"h":11}
{"text":"Reveal","x":47,"y":10,"w":81,"h":11}
(totally spent 61.1s – ends at 2024-11-28T11:31:09.192Z)

Details of the 6 uncovered mutations

Spec Tezos (6)

  • send revealed: balance is too low (2)
  • send max (non delegating): balance is too low (2)
  • delegate unrevealed: balance is too low (2)
  • delegate revealed: balance is too low (2)
  • undelegate unrevealed: balance is too low (2)
  • undelegate revealed: balance is too low (2)
Portfolio ($6.56) – Details of the 1 currencies
Spec (accounts) State Remaining Runs (est) funds?
Tezos (3) 156 ops , 5.28869 XTZ ($6.56) 👍 182 tz1aDK1uFAmnUXZ7KJPEmcCEFeYHiVZ56zVF
undefined: 5.28869 XTZ (152ops) (tz1aDK1uFAmnUXZ7KJPEmcCEFeYHiVZ56zVF on 44'/1729'/0'/0') tezbox#0 js:2:tezos:0240051fc51799e60dcc8870415b87fc4fd948e71b23fdc0d9b8ac7438cf7d4708:tezbox
undefined: 0 XTZ (4ops) (tz1he4fPXP3c9fFrztYT3k7KyYuLb28arFNn on 44'/1729'/1'/0') tezbox#1 js:2:tezos:02fe3d777af5380ef0a431c4985772c9669743050cee5feff717c3c3272d7a2810:tezbox
undefined: 0 XTZ (0ops) (tz1SApkt3kmMaqNE1qtgADc6m3B49HZkFVDA on 44'/1729'/2'/0') tezbox#2 js:2:tezos:029d7bcf10737806147b22ba4578747ce4ac53e26b443c9eb1ac0e4d5bfbb8f67e:tezbox
Performance ⏲ 70.6s

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL 228ms 4.1s 0.56ms 738ms N/A N/A N/A N/A
Tezos (2) 228ms 4.1s 0.56ms 738ms N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

Please sign in to comment.