Skip to content
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

Debug timeout of LedgerHQ/app-nervos #406

Closed
Keith-CY opened this issue Jun 24, 2024 · 3 comments
Closed

Debug timeout of LedgerHQ/app-nervos #406

Keith-CY opened this issue Jun 24, 2024 · 3 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@Keith-CY
Copy link
Member

There are 2 components for connection between Neuron and Ledger Wallet

  1. SDK running in the Client: https://github.com/obsidiansystems/hw-app-ckb
  2. App running in the Ledger Device: https://github.com/LedgerHQ/app-nervos

The App is being maintained at https://github.com/LedgerHQ/app-nervos and it was forked from https://github.com/obsidiansystems/ledger-app-nervos

Recently, the ledger team has tried to enable the CI of building the app(https://github.com/LedgerHQ/app-nervos/blob/develop/.github/workflows/continuous-integration-workflow.yml) but it failed (https://github.com/LedgerHQ/app-nervos/actions/runs/9211189099/job/25340021172) because of timeout.

The tests are written in JavaScript, so they want us to check if we can fix it.

@Keith-CY Keith-CY added the help wanted Extra attention is needed label Jun 24, 2024
@Keith-CY Keith-CY added this to Neuron Jun 24, 2024
@Keith-CY
Copy link
Member Author

I've run the CI of the original repo, and it failed due to the same reason
https://github.com/obsidiansystems/ledger-app-nervos/blob/develop/.github/workflows/continuous-integration-workflow.yml

@Danie0918 Danie0918 moved this to 🆕 New in Neuron Jun 24, 2024
@Danie0918 Danie0918 moved this from 🆕 New to 🏗 In Progress in Neuron Jul 1, 2024
@Danie0918 Danie0918 assigned homura and unassigned Danie0918 and yanguoyu Jul 1, 2024
@homura
Copy link

homura commented Jul 4, 2024

Setup the Development Environment

  1. git clone https://github.com/LedgerHQ/speculos.git
  2. docker build -f build.Dockerfile -t speculos-builder:latest .
  3. Patch Dockerfile
diff --git a/Dockerfile b/Dockerfile
index 1ab457b..8305c93 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,7 +4,7 @@
 #
 # Building the Speculos environment
-FROM ghcr.io/ledgerhq/speculos-builder:latest AS builder
+FROM speculos-builder:latest AS builder
  1. docker build -f Dockerfile -t speculos:latest .

Get the Compiled File from GitHub Artifact

Choose a app file from the workflow https://github.com/LedgerHQ/app-nervos/actions/workflows/continuous-integration-workflow.yml

image

Try the Speculos

docker run \
  -it \
  --rm \
  -v \
  $(pwd)/apps:/speculos/apps \ 
  --publish 8888:8888 \
  --publish 8899:8899 \
  --publish 9999:9999 \
    speculos apps/app.elf \
    --sdk 2.0 \
    --display headless \
    --button-port 8888 \
    --automation-port 8899 \
    --apdu-port 9999

Problems

Async Calls are not Robust

https://github.com/LedgerHQ/app-nervos/blob/5089b38d1551205928aba41a1c72b623e04b9d35/tests/sudt.js#L194-L202

      while((policy = await screens.next()).header != "Allow contract data") {
        speculos.button("Rr");
      }
      while(policy.body != target) {
        speculos.button("RLrl");
        policy = await screens.next();
      }
      do { speculos.button("Rr") } while((await screens.next()).body != "Main menu");
      speculos.button("RLrl");

The code here attempts to press buttons to navigate to a specific screen. However, the async function is not always predictable. The test snippet above shows its attempt to press the Rr button to reach a screen displaying "Allow contract data", but it might skip the target screen if Speculos fails to respond in time, resulting in pressing the button twice

Exit with the Code 255

ledger-app

Some necessary sleep is required after pressing a button, or the Ledger may not react in time, which could cause unexpected operations

Invalid Address

ckb1qpw9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn32s4l9ycxc8xncdtp2jzgcrhu6ggl3a7lgv0gzysy32

image
image
image
image
image
image
image

@homura
Copy link

homura commented Jul 12, 2024

LedgerHQ/app-nervos#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: ✅ Done
Development

No branches or pull requests

4 participants