diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index a70a783..cabc149 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -4,137 +4,138 @@ on: workflow_dispatch: push: branches: + - main - master - develop pull_request: - branches: - - master - - develop jobs: - - job_nano_build: - name: Build plugin + 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 + - 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 run: | - make BOLOS_SDK=${{ matrix.SDK }} + make BOLOS_SDK=${{ matrix.sdk }} -j - job_nano_build_testing: - name: Build plugin for testing + 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 + - 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 run: | - make DEBUG=1 BOLOS_SDK=${{ matrix.SDK }} + make DEBUG=1 BOLOS_SDK=${{ matrix.sdk }} -j + + - name: Rename binary + run: | mv bin/app.elf plugin_${{ matrix.name }}.elf - - name: Upload - uses: actions/upload-artifact@v2 + - name: Upload binary + uses: actions/upload-artifact@v3 with: name: binaries path: plugin_${{ matrix.name }}.elf - job_build_ethereum: - name: Build Ethereum application for Nano X & S/SP testing + 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 + - 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: Checkout app-ethereum - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: LedgerHQ/app-ethereum - ref: ${{ github.base_ref || github.ref_name }} - submodules: recursive + ref: ${{ ((github.base_ref || github.ref_name) == 'main' && 'master') || (github.base_ref || github.ref_name) }} - - name: Build ethereum + - name: Build run: | - make clean - make -j DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=${{ matrix.SDK }} CHAIN=ethereum + make DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=${{ matrix.sdk }} -j + - name: Rename binary run: | - mv bin/app.elf bin/ethereum_${{ matrix.name }}.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: ./bin/ethereum_${{ matrix.name }}.elf + path: ethereum_${{ matrix.name }}.elf - job-e2e-tests: - name: E2E tests for NanoS, X and S+ - needs: [job_nano_build_testing, job_build_ethereum] + jobs-e2e-tests: + name: E2E Tests + needs: [job_build_debug_plugin, job_build_debug_app] runs-on: ubuntu-latest steps: - - name: Clone - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 + + - name: Download built binaries + uses: actions/download-artifact@v3 + with: + name: binaries + path: tests/elfs/ - name: Install node - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: - node-version: "14.15.0" + node-version: "16.19.0" - name: Install yarn run: | npm install -g yarn - - name: Install JS dependencies + - name: Install JS deps run: | cd tests && yarn install - - name: Download binaries - uses: actions/download-artifact@v2 - with: - name: binaries - path: tests/elfs - - - name: Run zemu tests + - name: Run Zemu tests run: | cd tests && yarn test - diff --git a/.github/workflows/lint-workflow.yml b/.github/workflows/lint-workflow.yml index 4132df1..71e57a1 100644 --- a/.github/workflows/lint-workflow.yml +++ b/.github/workflows/lint-workflow.yml @@ -4,12 +4,10 @@ on: workflow_dispatch: push: branches: - - master - - develop + - main + - master + - develop pull_request: - branches: - - master - - develop jobs: job_lint: @@ -18,11 +16,11 @@ jobs: steps: - name: Clone - uses: actions/checkout@v2 + 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 diff --git a/Makefile b/Makefile index 7603553..a413471 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ APP_LOAD_PARAMS += $(COMMON_LOAD_PARAMS) APPVERSION_M = 2 APPVERSION_N = 1 -APPVERSION_P = 0 +APPVERSION_P = 1 APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P) APPNAME = "Paraswap" 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 diff --git a/src/handle_provide_parameter.c b/src/handle_provide_parameter.c index 26d4a6f..771291d 100644 --- a/src/handle_provide_parameter.c +++ b/src/handle_provide_parameter.c @@ -67,7 +67,9 @@ static void handle_uniswap_and_forks(ethPluginProvideParameter_t *msg, context->next_param = PATHS_OFFSET; break; case PATHS_OFFSET: - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->offset)); + if (!U2BE_from_parameter(msg->parameter, &context->offset)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } context->next_param = PATH; break; case PATH: // len(path) @@ -152,7 +154,9 @@ static void handle_multiswap(ethPluginProvideParameter_t *msg, paraswap_paramete } break; case PATHS_OFFSET: - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); + if (!U2BE_from_parameter(msg->parameter, &context->offset)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } context->next_param = PATHS_LEN; break; case PATHS_LEN: @@ -163,7 +167,9 @@ static void handle_multiswap(ethPluginProvideParameter_t *msg, paraswap_paramete PARAMETER_LENGTH; // Offset checkpoint starts after the length break; case OFFSET: - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); + if (!U2BE_from_parameter(msg->parameter, &context->offset)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } context->next_param = TOKEN_RECEIVED; break; case TOKEN_RECEIVED: @@ -265,7 +271,9 @@ static void handle_megaswap(ethPluginProvideParameter_t *msg, paraswap_parameter } break; case MEGA_PATHS_OFFSET: - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); + if (!U2BE_from_parameter(msg->parameter, &context->offset)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } context->next_param = MEGA_PATHS_LEN; break; case MEGA_PATHS_LEN: @@ -273,7 +281,9 @@ static void handle_megaswap(ethPluginProvideParameter_t *msg, paraswap_parameter break; case FIRST_MEGAPATH_OFFSET: context->checkpoint = msg->parameterOffset; - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); + if (!U2BE_from_parameter(msg->parameter, &context->offset)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } context->next_param = FIRST_MEGAPATH; break; case FIRST_MEGAPATH: @@ -281,17 +291,23 @@ static void handle_megaswap(ethPluginProvideParameter_t *msg, paraswap_parameter context->next_param = PATHS_OFFSET; break; case PATHS_OFFSET: - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); + if (!U2BE_from_parameter(msg->parameter, &context->offset)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } context->next_param = PATHS_LEN; break; case PATHS_LEN: - context->skip = U2BE(msg->parameter, PARAMETER_LENGTH - 2); + if (!U2BE_from_parameter(msg->parameter, &context->skip)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } context->skip--; // Decrease by one because we wish to acces path[-1]. context->next_param = PATH; break; case PATH: context->checkpoint = msg->parameterOffset; - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); + if (!U2BE_from_parameter(msg->parameter, &context->offset)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } context->next_param = TOKEN_RECEIVED; break; case TOKEN_RECEIVED: diff --git a/tests/elfs/ethereum_nanos.elf b/tests/elfs/ethereum_nanos.elf deleted file mode 100755 index ff13e2a..0000000 Binary files a/tests/elfs/ethereum_nanos.elf and /dev/null differ diff --git a/tests/elfs/ethereum_nanox.elf b/tests/elfs/ethereum_nanox.elf deleted file mode 100755 index f00f4c5..0000000 Binary files a/tests/elfs/ethereum_nanox.elf and /dev/null differ