Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 34 additions & 105 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,113 +10,23 @@
pull_request:

jobs:
job_build_release_plugin:
name: Build release plugin
strategy:
matrix:
include:
- sdk: "$NANOX_SDK"
name: "nanox"
- sdk: "$NANOSP_SDK"
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest

steps:
- name: Clone
uses: actions/checkout@v3
with:
submodules: recursive

- name: Build
run: |
make BOLOS_SDK=${{ matrix.sdk }} -j

job_build_debug_plugin:
name: Build debug plugin
strategy:
matrix:
include:
- sdk: "$NANOX_SDK"
name: "nanox"
- sdk: "$NANOSP_SDK"
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest

steps:
- name: Clone
uses: actions/checkout@v3
with:
submodules: recursive

- name: Build
run: |
make DEBUG=1 BOLOS_SDK=${{ matrix.sdk }} -j

- name: Rename binary
run: |
mv bin/app.elf plugin_${{ matrix.name }}.elf

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: plugin_binary_${{ matrix.name }}
path: plugin_${{ matrix.name }}.elf
name: Build plugin using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: "plugin_binaries"
flags: "DEBUG=1"

job_build_debug_app:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
name: Build debug Ethereum app
strategy:
matrix:
include:
- sdk: "$NANOX_SDK"
name: "nanox"
- sdk: "$NANOSP_SDK"
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest

steps:
- name: Checkout app-ethereum
uses: actions/checkout@v3
with:
repository: LedgerHQ/app-ethereum
submodules: recursive
ref: ${{ ((github.base_ref || github.ref_name) == 'main' && 'master') || (github.base_ref || github.ref_name) }}

- name: Build
run: |
make DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=${{ matrix.sdk }} -j

- name: Rename binary
run: |
mv bin/app.elf ethereum_${{ matrix.name }}.elf

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ethereum_binary_${{ matrix.name }}
path: ethereum_${{ matrix.name }}.elf
name: Build ethereum using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
app_repository: LedgerHQ/app-ethereum
app_branch_name: develop
upload_app_binaries_artifact: "eth_binaries"
flags: "DEBUG=1 BYPASS_SIGNATURES=1"

jobs-e2e-tests:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
name: E2E Tests
needs: [job_build_debug_plugin, job_build_debug_app]
runs-on: ubuntu-latest
Expand All @@ -127,9 +37,28 @@
- name: Download built binaries
uses: actions/download-artifact@v4
with:
pattern: "*_binary_*"
path: tests/elfs/
merge-multiple: true
name: plugin_binaries
path: plugin_binaries

- name: Download built binaries
uses: actions/download-artifact@v4
with:
name: eth_binaries
path: eth_binaries

- name: Dispatch binaries
run: |
mkdir tests/elfs

mv plugin_binaries/nanox/bin/app.elf tests/elfs/plugin_nanox.elf
mv plugin_binaries/nanos2/bin/app.elf tests/elfs/plugin_nanosp.elf
mv plugin_binaries/flex/bin/app.elf tests/elfs/plugin_flex.elf
mv plugin_binaries/stax/bin/app.elf tests/elfs/plugin_stax.elf

mv eth_binaries/nanox/bin/app.elf tests/elfs/ethereum_nanox.elf
mv eth_binaries/nanos2/bin/app.elf tests/elfs/ethereum_nanosp.elf
mv eth_binaries/flex/bin/app.elf tests/elfs/ethereum_flex.elf
mv eth_binaries/stax/bin/app.elf tests/elfs/ethereum_stax.elf

- name: Install node
uses: actions/setup-node@v3
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ APPNAME = "Velora"

# Application version
APPVERSION_M = 2
APPVERSION_N = 4
APPVERSION_P = 1
APPVERSION_N = 5
APPVERSION_P = 0

include ethereum-plugin-sdk/standard_plugin.mk
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 7 additions & 22 deletions fuzzing/fuzz_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
ethQueryContractUI_t query_ui = {0};
txContent_t content = {0};

// Fake sha3 context
cx_sha3_t sha3;

ethPluginSharedRO_t shared_ro;
shared_ro.txContent = &content;

ethPluginSharedRW_t shared_rw;
shared_rw.sha3 = &sha3;

paraswap_parameters_t context;
const uint8_t address[ADDRESS_LENGTH] = {0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
Expand All @@ -52,8 +43,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

init_contract.interfaceVersion = ETH_PLUGIN_INTERFACE_VERSION_LATEST;
init_contract.selector = data;
init_contract.pluginSharedRO = &shared_ro;
init_contract.pluginSharedRW = &shared_rw;
init_contract.txContent = &content;
init_contract.pluginContext = (uint8_t *) &context;
init_contract.pluginContextLength = sizeof(context);

Expand All @@ -68,8 +58,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
provide_param.parameter = data + i;
provide_param.parameterOffset = i;
provide_param.pluginContext = (uint8_t *) &context;
provide_param.pluginSharedRO = &shared_ro;
provide_param.pluginSharedRW = &shared_rw;
provide_param.txContent = &content;
handle_provide_parameter(&provide_param);
if (provide_param.result != ETH_PLUGIN_RESULT_OK) {
return 0;
Expand All @@ -79,17 +68,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

finalize.pluginContext = (uint8_t *) &context;
finalize.address = address;
finalize.pluginSharedRO = &shared_ro;
finalize.pluginSharedRW = &shared_rw;
finalize.txContent = &content;
handle_finalize(&finalize);
if (finalize.result != ETH_PLUGIN_RESULT_OK) {
return 0;
}

if (finalize.tokenLookup1 || finalize.tokenLookup2) {
provide_info.pluginContext = (uint8_t *) &context;
provide_info.pluginSharedRO = &shared_ro;
provide_info.pluginSharedRW = &shared_rw;
provide_info.txContent = &content;
if (finalize.tokenLookup1) {
if (size - i >= sizeof(extraInfo_t)) {
provide_info.item1 = &item1;
Expand Down Expand Up @@ -117,8 +104,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}

query_id.pluginContext = (uint8_t *) &context;
query_id.pluginSharedRO = &shared_ro;
query_id.pluginSharedRW = &shared_rw;
query_id.txContent = &content;
query_id.name = name;
query_id.nameLength = sizeof(name);
query_id.version = version;
Expand All @@ -138,8 +124,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
query_ui.msg = msg;
query_ui.msgLength = sizeof(msg);
query_ui.pluginContext = (uint8_t *) &context;
query_ui.pluginSharedRO = &shared_ro;
query_ui.pluginSharedRW = &shared_rw;
query_ui.txContent = &content;

query_ui.screenIndex = i;
handle_query_contract_ui(&query_ui);
Expand All @@ -150,4 +135,4 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}

return 0;
}
}
Binary file added fuzzing/out/fuzz
Binary file not shown.
Binary file added fuzzing/out/llvm-symbolizer
Binary file not shown.
Binary file added glyphs/apex_velora_48px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/apex_app_velora.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ledger_app.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[app]
build_directory = "./"
sdk = "C"
devices = ["nanox", "nanos+", "stax", "flex"]
devices = ["apex_p", "nanox", "nanos+", "stax", "flex"]
2 changes: 1 addition & 1 deletion src/contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
********************************************************************************/

#include <stdint.h>
#include "paraswap_plugin.h"
#include "plugin.h"

// ---------- Paraswap V5 -------------

Expand Down
5 changes: 2 additions & 3 deletions src/handle_finalize.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "paraswap_plugin.h"
#include "plugin.h"

void handle_finalize(ethPluginFinalize_t *msg) {
paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext;
Expand All @@ -20,8 +20,7 @@ void handle_finalize(ethPluginFinalize_t *msg) {
context->contract_address_sent);

// The user is not swapping ETH, so make sure there's no ETH being sent in this tx.
if (!allzeroes(msg->pluginSharedRO->txContent->value.value,
msg->pluginSharedRO->txContent->value.length)) {
if (!allzeroes(msg->txContent->value.value, msg->txContent->value.length)) {
PRINTF("ETH attached to tx when token being swapped is %.*H\n",
sizeof(context->contract_address_sent),
context->contract_address_sent);
Expand Down
2 changes: 1 addition & 1 deletion src/handle_init_contract.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "paraswap_plugin.h"
#include "plugin.h"

// Called once to init.
void handle_init_contract(ethPluginInitContract_t *msg) {
Expand Down
2 changes: 1 addition & 1 deletion src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "paraswap_plugin.h"
#include "plugin.h"

// Copy amount sent parameter to amount_sent
static void handle_amount_sent(const ethPluginProvideParameter_t *msg,
Expand Down
2 changes: 1 addition & 1 deletion src/handle_provide_token.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "paraswap_plugin.h"
#include "plugin.h"

void handle_provide_token(ethPluginProvideInfo_t *msg) {
paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext;
Expand Down
2 changes: 1 addition & 1 deletion src/handle_query_contract_id.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "paraswap_plugin.h"
#include "plugin.h"

void handle_query_contract_id(ethQueryContractID_t *msg) {
const paraswap_parameters_t *context = (paraswap_parameters_t *) msg->pluginContext;
Expand Down
2 changes: 1 addition & 1 deletion src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <stdbool.h>
#include "paraswap_plugin.h"
#include "plugin.h"

// Set UI for the "Send" screen.
static bool set_send_ui(ethQueryContractUI_t *msg, paraswap_parameters_t *context) {
Expand Down
4 changes: 4 additions & 0 deletions src/paraswap_plugin.h → src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ typedef struct paraswap_parameters_t {
uint8_t array_len;
// 8*1 + 2*3 == 8 + 6 == 14 bytes. There are 14 - 14 == 0 byte left.
} paraswap_parameters_t;

// Check that the plugin context structure will fit in the ethereum allocated memory.
// Do not remove this check.
ASSERT_SIZEOF_PLUGIN_CONTEXT(paraswap_parameters_t);
Loading