From 4df65d29c8cb7dec8c343651b47229a35453cbdc Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Mon, 30 Jan 2023 11:40:40 +0100 Subject: [PATCH 1/5] Updated plugin SDK --- ethereum-plugin-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum-plugin-sdk b/ethereum-plugin-sdk index 0de74c6..a4b971f 160000 --- a/ethereum-plugin-sdk +++ b/ethereum-plugin-sdk @@ -1 +1 @@ -Subproject commit 0de74c6382f876f89f82ef0eef90408fd94888a3 +Subproject commit a4b971f67980694d8c3862e793859209bc525545 From 12654ccb3af0cf17cce3eb9c6072158a80b83153 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Mon, 30 Jan 2023 11:53:23 +0100 Subject: [PATCH 2/5] Fixed CI deprecation warnings --- .github/workflows/ci-workflow.yml | 265 ++++++++++------------------ .github/workflows/lint-workflow.yml | 11 +- 2 files changed, 94 insertions(+), 182 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 7d358a3..dfc6422 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -1,57 +1,59 @@ name: Compilation & tests on: + workflow_dispatch: push: branches: - main + - master - develop pull_request: - branches: - - main - - develop jobs: - job_build_debug: - name: Build debug - runs-on: ubuntu-latest + job_build_release_plugin: + name: Build release plugin + strategy: + matrix: + include: + - sdk: "$NANOS_SDK" + name: "nanos" + - sdk: "$NANOX_SDK" + name: "nanox" + - sdk: "$NANOSP_SDK" + name: "nanosp" + runs-on: ubuntu-latest container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest + image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest steps: - name: Clone - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: recursive - - name: Build Ledger NFT plugin + - name: Build run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - make DEBUG=1 - - - name: Upload Ledger NFT binary - uses: actions/upload-artifact@v2 - with: - name: ledger-nft-app-debug - path: bin + make BOLOS_SDK=${{ matrix.sdk }} -j job_scan_build: name: Clang Static Analyzer - needs: job_build_debug runs-on: ubuntu-latest container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest + image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + with: + submodules: recursive - name: Build with Clang Static Analyzer run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" - make clean scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default - - uses: actions/upload-artifact@v2 + + - uses: actions/upload-artifact@v3 if: failure() with: name: scan-build @@ -59,20 +61,21 @@ jobs: job_coverity_scan: name: Coverity Scan - needs: job_build_debug runs-on: ubuntu-latest container: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-scanner:latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + with: + submodules: recursive - name: Build with cov-build run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" - make clean cov-build --dir cov-int make default + - name: Submit the result to Coverity Scan run: | tar czvf cov-int.tar.gz cov-int @@ -86,197 +89,107 @@ jobs: env: EMAIL: ${{ secrets.COVERITY_SCAN_EMAIL }} TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} - job_build_debug_nano_s: - name: Build debug Nano S - runs-on: ubuntu-latest - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest - steps: - - name: Clone - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Build plugin for Nano S - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - make clean - make BOLOS_SDK=$NANOS_SDK - - name: Move binary to test directory - run: | - mkdir -p ./tests/elfs/ - mv bin/app.elf ./tests/elfs/ledger_nft_nanos.elf - - name: Upload plugin binary - uses: actions/upload-artifact@v2 - with: - name: binaries - path: tests/elfs/ledger_nft_nanos.elf - job_build_debug_nano_sp: - name: Build debug Nano S+ - runs-on: ubuntu-latest - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest - steps: - - name: Clone - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Build plugin for Nano S+ - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - make clean - make BOLOS_SDK=$NANOSP_SDK - - name: Move binary to test directory - run: | - mkdir -p ./tests/elfs/ - mv bin/app.elf ./tests/elfs/ledger_nft_nanosp.elf - - name: Upload plugin binary - uses: actions/upload-artifact@v2 - with: - name: binaries - path: tests/elfs/ledger_nft_nanosp.elf + job_build_debug_plugin: + name: Build debug plugin + strategy: + matrix: + include: + - sdk: "$NANOS_SDK" + name: "nanos" + - sdk: "$NANOX_SDK" + name: "nanox" + - sdk: "$NANOSP_SDK" + name: "nanosp" - job_build_debug_nano_x: - name: Build debug Nano X runs-on: ubuntu-latest container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest + image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest + steps: - name: Clone - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: recursive - - name: Build plugin for Nano X - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - make clean - make BOLOS_SDK=$NANOX_SDK - - name: Move binary to test directory - run: | - mkdir -p ./tests/elfs/ - mv bin/app.elf ./tests/elfs/ledger_nft_nanox.elf - - name: Upload plugin binary - uses: actions/upload-artifact@v2 - with: - name: binaries - path: tests/elfs/ledger_nft_nanox.elf - job_build_ethereum_nano_s: - name: Build Ethereum application for Nano S testing - runs-on: ubuntu-latest - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest - steps: - - name: Checkout app-ethereum - uses: actions/checkout@v2 - with: - repository: LedgerHQ/app-ethereum - ref: ${{ ((github.base_ref || github.ref_name) == 'main' && 'master') || (github.base_ref || github.ref_name) }} - submodules: recursive - - name: Build ethereum - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - make clean - make -j DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=$NANOS_SDK CHAIN=ethereum ALLOW_DATA=1 - - name: Move binary to test directory + - name: Build run: | - mkdir -p ./tests/elfs/ - mv bin/app.elf ./tests/elfs/ethereum_nanos.elf - - name: Upload plugin binary - uses: actions/upload-artifact@v2 - with: - name: binaries - path: tests/elfs/ethereum_nanos.elf + make DEBUG=1 BOLOS_SDK=${{ matrix.sdk }} -j - job_build_ethereum_nano_sp: - name: Build Ethereum application for Nano S+ testing - runs-on: ubuntu-latest - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest - steps: - - name: Checkout app-ethereum - uses: actions/checkout@v2 - with: - repository: LedgerHQ/app-ethereum - ref: ${{ ((github.base_ref || github.ref_name) == 'main' && 'master') || (github.base_ref || github.ref_name) }} - submodules: recursive - - name: Build ethereum - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - make clean - make -j DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=$NANOSP_SDK CHAIN=ethereum ALLOW_DATA=1 - - name: Move binary to test directory + - name: Rename binary run: | - mkdir -p ./tests/elfs/ - mv bin/app.elf ./tests/elfs/ethereum_nanosp.elf - - name: Upload plugin binary - uses: actions/upload-artifact@v2 + mv bin/app.elf plugin_${{ matrix.name }}.elf + + - name: Upload binary + uses: actions/upload-artifact@v3 with: name: binaries - path: tests/elfs/ethereum_nanosp.elf + path: plugin_${{ matrix.name }}.elf + + job_build_debug_app: + name: Build debug Ethereum app + strategy: + matrix: + include: + - sdk: "$NANOS_SDK" + name: "nanos" + - sdk: "$NANOX_SDK" + name: "nanox" + - sdk: "$NANOSP_SDK" + name: "nanosp" - job_build_ethereum_nano_x: - name: Build Ethereum application for Nano X testing runs-on: ubuntu-latest container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest + image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest + steps: - name: Checkout app-ethereum - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: LedgerHQ/app-ethereum ref: ${{ ((github.base_ref || github.ref_name) == 'main' && 'master') || (github.base_ref || github.ref_name) }} - submodules: recursive - - name: Build ethereum + + - name: Build run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - make clean - make -j DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=$NANOX_SDK CHAIN=ethereum ALLOW_DATA=1 - - name: Move binary to test directory + make DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=${{ matrix.sdk }} -j + + - name: Rename binary run: | - mkdir -p ./tests/elfs/ - mv bin/app.elf ./tests/elfs/ethereum_nanox.elf - - name: Upload plugin binary - uses: actions/upload-artifact@v2 + mv bin/app.elf ethereum_${{ matrix.name }}.elf + + - name: Upload binary + uses: actions/upload-artifact@v3 with: name: binaries - path: tests/elfs/ethereum_nanox.elf + path: ethereum_${{ matrix.name }}.elf jobs-e2e-tests: - needs: - - job_build_debug_nano_s - - job_build_debug_nano_sp - - job_build_debug_nano_x - - job_build_ethereum_nano_s - - job_build_ethereum_nano_sp - - job_build_ethereum_nano_x + name: E2E Tests + needs: [job_build_debug_plugin, job_build_debug_app] runs-on: ubuntu-latest steps: - - name: Test - run: | - id - echo $HOME - echo $DISPLAY - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + - name: Download built binaries - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: binaries path: tests/elfs/ - - name: Check downloaded binaries - run: ls -lh ./tests/elfs - - run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev + - name: Install node - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: - node-version: "16.4.0" + node-version: "16.19.0" + - name: Install yarn run: | npm install -g yarn - - name: Build/Install build js deps + + - name: Install JS deps run: | cd tests && yarn install - - name: Run zemu tests + + - name: Run Zemu tests run: | - cd tests && yarn test \ No newline at end of file + cd tests && yarn test diff --git a/.github/workflows/lint-workflow.yml b/.github/workflows/lint-workflow.yml index 0565b19..8a4621f 100644 --- a/.github/workflows/lint-workflow.yml +++ b/.github/workflows/lint-workflow.yml @@ -1,14 +1,13 @@ name: Code style check on: + workflow_dispatch: push: branches: - - main - - develop + - main + - master + - develop pull_request: - branches: - - main - - develop jobs: job_lint: @@ -17,7 +16,7 @@ jobs: steps: - name: Clone - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Lint uses: DoozyX/clang-format-lint-action@v0.13 From 8a32c318f768c00442cb2db3a57cde9ce726cf56 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Wed, 1 Feb 2023 17:34:18 +0100 Subject: [PATCH 3/5] Updated linting settings --- .github/workflows/lint-workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-workflow.yml b/.github/workflows/lint-workflow.yml index 8a4621f..71e57a1 100644 --- a/.github/workflows/lint-workflow.yml +++ b/.github/workflows/lint-workflow.yml @@ -19,8 +19,8 @@ jobs: uses: actions/checkout@v3 - name: Lint - uses: DoozyX/clang-format-lint-action@v0.13 + uses: DoozyX/clang-format-lint-action@v0.15 with: source: "./" extensions: "h,c" - clangFormatVersion: 12.0.0 + clangFormatVersion: 12.0.1 From 653ae586ec3d791330f63c9014c0571d688e7c8c Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Mon, 30 Jan 2023 12:00:37 +0100 Subject: [PATCH 4/5] Fix Zemu tests --- tests/src/test.fixture.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/src/test.fixture.js b/tests/src/test.fixture.js index 6eeeaaa..7cdcb7f 100644 --- a/tests/src/test.fixture.js +++ b/tests/src/test.fixture.js @@ -19,9 +19,9 @@ const NANOS_ETH_PATH = Resolve("elfs/ethereum_nanos.elf"); const NANOSP_ETH_PATH = Resolve("elfs/ethereum_nanosp.elf"); const NANOX_ETH_PATH = Resolve("elfs/ethereum_nanox.elf"); -const NANOS_PLUGIN_PATH = Resolve("elfs/ledger_nft_nanos.elf"); -const NANOSP_PLUGIN_PATH = Resolve("elfs/ledger_nft_nanosp.elf"); -const NANOX_PLUGIN_PATH = Resolve("elfs/ledger_nft_nanox.elf"); +const NANOS_PLUGIN_PATH = Resolve("elfs/plugin_nanos.elf"); +const NANOSP_PLUGIN_PATH = Resolve("elfs/plugin_nanosp.elf"); +const NANOX_PLUGIN_PATH = Resolve("elfs/plugin_nanox.elf"); const NANOS_PLUGIN = { LedgerNFT: NANOS_PLUGIN_PATH }; const NANOSP_PLUGIN = { LedgerNFT: NANOSP_PLUGIN_PATH }; @@ -82,7 +82,7 @@ function txFromEtherscan(rawTx) { * Emulation of the device using zemu * @param {string} device name of the device to emulate (nanos, nanox) * @param {function} func - * @param {boolean} signed the plugin is already signed + * @param {boolean} signed the plugin is already signed * @returns {Promise} */ function zemu(device, func, testNetwork, signed = false) { @@ -91,7 +91,7 @@ function zemu(device, func, testNetwork, signed = false) { let eth_path; let plugin; let sim_options = sim_options_generic; - + if (device === "nanos") { eth_path = NANOS_ETH_PATH; plugin = NANOS_PLUGIN; @@ -105,14 +105,14 @@ function zemu(device, func, testNetwork, signed = false) { plugin = NANOX_PLUGIN; sim_options.model = "nanox"; } - + const sim = new Zemu(eth_path, plugin); - + try { await sim.start(sim_options); const transport = await sim.getTransport(); const eth = new Eth(transport); - + if (!signed) { config = generate_plugin_config(testNetwork); eth.setLoadConfig({ @@ -215,4 +215,4 @@ module.exports = { populateTransaction, zemu, genericTx -}; \ No newline at end of file +}; From 80d6c2bccbfbe32b0f1f668e571e1b70d1ccafac Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Mon, 30 Jan 2023 11:54:27 +0100 Subject: [PATCH 5/5] Bumped plugin version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7600ca0..1df50e8 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ APP_LOAD_PARAMS += $(COMMON_LOAD_PARAMS) APPVERSION_M = 1 APPVERSION_N = 1 -APPVERSION_P = 0 +APPVERSION_P = 1 APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P) APPNAME = "[ L ] Market"