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

Sync fork #9

Merged
merged 44 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
53200e6
The Ethereum client python package is directly retrieved from PyPi in…
tdejoigny-ledger Jan 15, 2024
4c923d8
Merge pull request #130 from LedgerHQ/tdj/update_test_requ
tdejoigny-ledger Jan 25, 2024
d1a5fb4
Update plugin SDK
apaillier-ledger Feb 2, 2024
c4585b8
Merge pull request #134 from LedgerHQ/feat/apa/update_plugin_sdk
fbeutin-ledger Feb 2, 2024
f0ea4af
Fix fuzzing compilation
apaillier-ledger Feb 2, 2024
8dbd4d7
Merge pull request #135 from LedgerHQ/fix/apa/fuzzing
apaillier-ledger Feb 2, 2024
8c740f8
ethereum-plugin-sdk: Update submodule reference
Feb 7, 2024
7aa3a8b
Merge pull request #136 from LedgerHQ/xch/bump-ethereum-sdk
xchapron-ledger Feb 7, 2024
4661094
Fix fuzzer compilation by adding HAVE_SHA224
cedelavergne-ledger Feb 22, 2024
6b4ace4
Merge pull request #137 from LedgerHQ/cev/fix_fuzzing_after_sdk_update
fbeutin-ledger Feb 22, 2024
0fd0119
Update snapshots for latest stax sdk
fbeutin-ledger Feb 22, 2024
53c7b7b
Merge pull request #138 from LedgerHQ/fbe/update_snapshots
fbeutin-ledger Feb 22, 2024
7e6cccc
Add test dependencies in manifest for ragger tests
fbeutin-ledger Jan 24, 2024
ea2f304
Merge pull request #131 from LedgerHQ/fbe/add_test_dependencies_in_ma…
fbeutin-ledger Feb 22, 2024
4502501
Update gitignore for tests dependencies and update the test dependenc…
tdejoigny-ledger Feb 26, 2024
d4cf76f
Merge pull request #139 from LedgerHQ/tdj/update_manifest_for_tests
tdejoigny-ledger Feb 26, 2024
21995b0
[auto] Update screenshot
sgliner-ledger Feb 27, 2024
2a924a7
Test now verifies the signature against the wallet's address
apaillier-ledger Feb 28, 2024
08dc462
Merge pull request #140 from LedgerHQ/feat/apa/signature_verification
apaillier-ledger Feb 29, 2024
2bcd2bf
Fix tests following ragger update v1.16.0
fbeutin-ledger Apr 3, 2024
569d064
Fix tests following eth client update
fbeutin-ledger Apr 3, 2024
3b215f2
Bump ethereum-plugin-sdk
fbeutin-ledger Apr 3, 2024
75e1519
Merge pull request #142 from LedgerHQ/fbe/fix_tests
fbeutin-ledger Apr 3, 2024
1fa4098
Remove deprecated configuration LOAD_MAIN_APP_AS_LIBRARY in ragger
fbeutin-ledger Apr 4, 2024
d0648fb
Merge pull request #143 from LedgerHQ/fbe/remove_deprecated_ragger_conf
fbeutin-ledger Apr 4, 2024
0c7bf5c
Sync fork
shahthepro Apr 9, 2024
99cf7ab
Merge branch 'develop' of https://github.com/LedgerHQ/app-plugin-boil…
shahthepro Apr 9, 2024
66ccc1a
Update SDK
shahthepro Apr 9, 2024
c141bf7
Update plugin SDK
shahthepro Apr 9, 2024
bcff06f
Fix import
shahthepro Apr 9, 2024
706b5dd
Remove deprecated files
shahthepro Apr 9, 2024
4f41d63
Fix tests
shahthepro Apr 9, 2024
b6bacd9
Remove test builds
shahthepro Apr 9, 2024
bdbbb57
Update stax images
shahthepro Apr 9, 2024
a9ca8e9
Verify sign
shahthepro Apr 9, 2024
69fda84
Fix derivation path
shahthepro Apr 9, 2024
f41df6c
Fix import
shahthepro Apr 9, 2024
5b2f7cd
Fix test utils
shahthepro Apr 9, 2024
a2693c0
Fix wrap tests
shahthepro Apr 9, 2024
097be1b
Fix params
shahthepro Apr 9, 2024
4e165f2
Fix nanos tests
shahthepro Apr 9, 2024
7875bfc
Fix is_nano check
shahthepro Apr 9, 2024
ae6e4bf
Update nanos snaps
shahthepro Apr 10, 2024
137006c
Fix more snaps
shahthepro Apr 10, 2024
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
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
- [ ] Target branch is `develop` <!-- unless you have a very good reason -->
- [ ] Application version has been bumped <!-- required if your changes are to be deployed -->

<!-- Make sure you followed the process described in https://developers.ledger.com/docs/embedded-app/maintenance/ before opening your Pull Request.
<!-- Make sure you followed the process described in https://developers.ledger.com/docs/device-app/deliver/maintenance before opening your Pull Request.
Don't hesitate to contact us directly on Discord if you have any questions ! https://developers.ledger.com/discord -->
2 changes: 1 addition & 1 deletion .github/workflows/build_and_functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
with:
download_app_binaries_artifact: plugin_binaries
additional_app_binaries_artifact: ethereum_build_develop
additional_app_binaries_artifact_dir: ./tests/ethereum_build/build
additional_app_binaries_artifact_dir: ./tests/.test_dependencies/ethereum/build
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ ledger/
tests/snapshots-tmp/

# Directory storing the ethereum build output for tests run
tests/ethereum_build/build/
tests/.test_dependencies/*
!tests/.test_dependencies/ethereum/
tests/.test_dependencies/ethereum/*
!tests/.test_dependencies/ethereum/.ethereum_application_build_goes_there

.DS_Store
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "ethereum-plugin-sdk"]
path = ethereum-plugin-sdk
url = https://github.com/LedgerHQ/ethereum-plugin-sdk
url = https://github.com/LedgerHQ/ethereum-plugin-sdk
14 changes: 9 additions & 5 deletions fuzzing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ set(CMAKE_C_STANDARD_REQUIRED True)
# compatible with ClusterFuzzLite
if (NOT DEFINED ENV{LIB_FUZZING_ENGINE})
set(COMPILATION_FLAGS_ "-fsanitize=fuzzer,address,undefined,signed-integer-overflow")
else()
else()
set(COMPILATION_FLAGS_ "$ENV{LIB_FUZZING_ENGINE} $ENV{CFLAGS}")
endif()
endif()
string(REPLACE " " ";" COMPILATION_FLAGS ${COMPILATION_FLAGS_})

add_compile_options(-Wall -Wextra -g -pedantic)
Expand Down Expand Up @@ -65,6 +65,7 @@ add_compile_definitions(
HAVE_EDDSA
HAVE_HASH
HAVE_BLAKE2
HAVE_SHA224
HAVE_SHA256
HAVE_SHA3
HAVE_SHA512
Expand All @@ -75,7 +76,7 @@ include_directories(
${BOLOS_SDK}/lib_cxng/include
${BOLOS_SDK}/lib_cxng/src
${BOLOS_SDK}/target/nanox/include
${ETH_DIR}/include
${ETH_DIR}/src
${SRC_DIR}
)

Expand All @@ -92,8 +93,11 @@ add_executable(fuzz
${SRC_DIR}/handle_query_contract_id.c

# Ethereum SDK
${ETH_DIR}/include/eth_internals.c
${ETH_DIR}/include/plugin_utils.c
${ETH_DIR}/src/common_utils.c
${ETH_DIR}/src/plugin_utils.c

# sdk utils
${BOLOS_SDK}/src/ledger_assert.c

# cxng
${BOLOS_SDK}/lib_cxng/src/cx_hash.c
Expand Down
13 changes: 13 additions & 0 deletions fuzzing/mocks.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "plugin.h"
#include "lcx_common.h"
#include "lcx_hash.h"
#include <stddef.h>

size_t strlcat(char *dst, const char *src, size_t size) {
size_t srclen; /* Length of source string */
Expand Down Expand Up @@ -33,3 +36,13 @@ size_t strlcpy(char *dst, const char *src, size_t size) {

return (srclen);
}

cx_err_t cx_keccak_256_hash_iovec(const cx_iovec_t *iovec,
size_t iovec_len,
uint8_t digest[static CX_KECCAK_256_SIZE]) {
return CX_OK;
}

void os_sched_exit(bolos_task_status_t exit_code) {
return;
}
9 changes: 9 additions & 0 deletions ledger_app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ devices = ["nanos", "nanox", "nanos+", "stax"]

[tests]
pytest_directory = "./tests/"

[tests.dependencies]
testing_with_latest = [
{url = "https://github.com/LedgerHQ/app-ethereum", ref = "develop", use_case = "use_test_keys"},
]

testing_with_prod = [
{url = "https://github.com/LedgerHQ/app-ethereum", ref = "master", use_case = "use_test_keys"},
]
1 change: 0 additions & 1 deletion src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ static bool set_beneficiary_ui(ethQueryContractUI_t *msg, context_t *context) {
return getEthAddressStringFromBinary(
context->beneficiary,
msg->msg + 2, // +2 here because we've already prefixed with '0x'.
msg->pluginSharedRW->sha3,
chainid);
}

Expand Down
2 changes: 0 additions & 2 deletions src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#pragma once

#include <string.h>

#include "eth_internals.h"
#include "eth_plugin_interface.h"

// All possible selectors of your plugin.
Expand Down
17 changes: 9 additions & 8 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ In order to run the tests you need to provide the binaries for both the plugin a

Compiling the plugin will produce the binary for the targeted device. They will be used as-is by the test framework.

The binaries of the Ethereum application must be gathered and placed in the directory `tests/ethereum_build/`.
The binaries of the Ethereum application must be gathered and placed in the directory `tests/.test_dependencies/ethereum/`.
Example of the correct file tree with Ethereum compiled for all targets.
* `tests/ethereum_build/build/nanos/bin/app.elf`
* `tests/ethereum_build/build/nanos2/bin/app.elf`
* `tests/ethereum_build/build/nanox/bin/app.elf`
* `tests/ethereum_build/build/stax/bin/app.elf`

The first method is to go in the Ethereum project, compile the application, and dispatch the `build/` output directory.
A second method is to re-use the Ethereum build used in the CI, and available as artifact.
* `tests/.test_dependencies/ethereum/build/nanos/bin/app.elf`
* `tests/.test_dependencies/ethereum/build/nanos2/bin/app.elf`
* `tests/.test_dependencies/ethereum/build/nanox/bin/app.elf`
* `tests/.test_dependencies/ethereum/build/stax/bin/app.elf`

The first method is to use the Ledger VSCode extension to automatically manage dependencies
The second method is to go in the Ethereum project, compile the application, and dispatch the `build/` output directory.
A third method is to re-use the Ethereum build used in the CI, and available as artifact.
For example in the [plugin-boilerplate CI](https://github.com/LedgerHQ/app-plugin-boilerplate/actions/workflows/build_and_functional_tests.yml).


Expand Down
12 changes: 9 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import pytest

from ragger.conftest import configuration
from .utils import WalletAddr


###########################
### CONFIGURATION START ###
Expand All @@ -7,9 +11,7 @@
# You can configure optional parameters by overriding the value of ragger.configuration.OPTIONAL_CONFIGURATION
# Please refer to ragger/conftest/configuration.py for their descriptions and accepted values

configuration.OPTIONAL.APP_DIR = "tests/ethereum_build/"

configuration.OPTIONAL.LOAD_MAIN_APP_AS_LIBRARY = True
configuration.OPTIONAL.MAIN_APP_DIR = "tests/.test_dependencies/"

configuration.OPTIONAL.BACKEND_SCOPE = "class"

Expand All @@ -20,3 +22,7 @@

# Pull all features from the base ragger conftest using the overridden configuration
pytest_plugins = ("ragger.conftest.base_conftest", )

@pytest.fixture
def wallet_addr(backend):
return WalletAddr(backend)
Binary file removed tests/ethereum_build/.DS_Store
Binary file not shown.
Empty file.
28 changes: 14 additions & 14 deletions tests/oeth/test_oeth_curve_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
"curve-router"
)

def test_oeth_curve_swap_from_oeth(backend, firmware, navigator, test_name):
def test_oeth_curve_swap_from_oeth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_curve_pool.encodeABI("exchange", [
1,
0,
Web3.to_wei(1, "ether"),
Web3.to_wei(0.975, "ether")
])

run_test(contract_curve_pool, data, backend, firmware, navigator, test_name)
run_test(contract_curve_pool, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_curve_swap_to_oeth(backend, firmware, navigator, test_name):
def test_oeth_curve_swap_to_oeth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_curve_pool.encodeABI("exchange", [
0,
1,
Web3.to_wei(1, "ether"),
Web3.to_wei(0.995, "ether")
])

run_test(contract_curve_pool, data, backend, firmware, navigator, test_name)
run_test(contract_curve_pool, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_curve_swap_multiple_oeth_to_reth(backend, firmware, navigator, test_name):
def test_oeth_curve_swap_multiple_oeth_to_reth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_curve_router.encodeABI("exchange_multiple", [
[
bytes.fromhex("856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3"),
Expand All @@ -54,9 +54,9 @@ def test_oeth_curve_swap_multiple_oeth_to_reth(backend, firmware, navigator, tes
Web3.to_wei(0.941, "ether"),
])

run_test(contract_curve_router, data, backend, firmware, navigator, test_name)
run_test(contract_curve_router, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_curve_swap_multiple_reth_to_oeth(backend, firmware, navigator, test_name):
def test_oeth_curve_swap_multiple_reth_to_oeth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_curve_router.encodeABI("exchange_multiple", [
[
bytes.fromhex("ae78736cd615f374d3085123a210448e74fc6393"),
Expand All @@ -79,9 +79,9 @@ def test_oeth_curve_swap_multiple_reth_to_oeth(backend, firmware, navigator, tes
Web3.to_wei(0.941, "ether"),
])

run_test(contract_curve_router, data, backend, firmware, navigator, test_name)
run_test(contract_curve_router, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_curve_swap_multiple_eth_to_oeth(backend, firmware, navigator, test_name):
def test_oeth_curve_swap_multiple_eth_to_oeth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_curve_router.encodeABI("exchange_multiple", [
[
bytes.fromhex("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"),
Expand All @@ -104,9 +104,9 @@ def test_oeth_curve_swap_multiple_eth_to_oeth(backend, firmware, navigator, test
Web3.to_wei(0.941, "ether"),
])

run_test(contract_curve_router, data, backend, firmware, navigator, test_name)
run_test(contract_curve_router, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_curve_swap_multiple_oeth_to_eth(backend, firmware, navigator, test_name):
def test_oeth_curve_swap_multiple_oeth_to_eth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_curve_router.encodeABI("exchange_multiple", [
[
bytes.fromhex("856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3"),
Expand All @@ -129,9 +129,9 @@ def test_oeth_curve_swap_multiple_oeth_to_eth(backend, firmware, navigator, test
Web3.to_wei(0.941, "ether"),
])

run_test(contract_curve_router, data, backend, firmware, navigator, test_name)
run_test(contract_curve_router, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_curve_swap_multiple_eth_to_oeth_diff_route(backend, firmware, navigator, test_name):
def test_oeth_curve_swap_multiple_eth_to_oeth_diff_route(backend, firmware, navigator, test_name, wallet_addr):
data = contract_curve_router.encodeABI("exchange_multiple", [
[
bytes.fromhex("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"),
Expand All @@ -154,4 +154,4 @@ def test_oeth_curve_swap_multiple_eth_to_oeth_diff_route(backend, firmware, navi
Web3.to_wei(0.941, "ether"),
])

run_test(contract_curve_router, data, backend, firmware, navigator, test_name)
run_test(contract_curve_router, data, backend, firmware, navigator, test_name, wallet_addr)
20 changes: 10 additions & 10 deletions tests/oeth/test_oeth_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,46 @@
"vault-core"
)

def test_oeth_vault_mint_weth(backend, firmware, navigator, test_name):
def test_oeth_vault_mint_weth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_oeth_vault.encodeABI("mint", [
bytes.fromhex("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
Web3.to_wei(1, "ether"),
Web3.to_wei(1, "ether")
])

run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name)
run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_vault_mint_reth(backend, firmware, navigator, test_name):
def test_oeth_vault_mint_reth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_oeth_vault.encodeABI("mint", [
bytes.fromhex("ae78736cd615f374d3085123a210448e74fc6393"),
Web3.to_wei(1, "ether"),
Web3.to_wei(1, "ether")
])

run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name)
run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_vault_mint_steth(backend, firmware, navigator, test_name):
def test_oeth_vault_mint_steth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_oeth_vault.encodeABI("mint", [
bytes.fromhex("ae7ab96520de3a18e5e111b5eaab095312d7fe84"),
Web3.to_wei(1, "ether"),
Web3.to_wei(1, "ether")
])

run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name)
run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_vault_mint_frxeth(backend, firmware, navigator, test_name):
def test_oeth_vault_mint_frxeth(backend, firmware, navigator, test_name, wallet_addr):
data = contract_oeth_vault.encodeABI("mint", [
bytes.fromhex("5e8422345238f34275888049021821e8e08caa1f"),
Web3.to_wei(1, "ether"),
Web3.to_wei(1, "ether")
])

run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name)
run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_vault_redeem(backend, firmware, navigator, test_name):
def test_oeth_vault_redeem(backend, firmware, navigator, test_name, wallet_addr):
data = contract_oeth_vault.encodeABI("redeem", [
Web3.to_wei(1, "ether"),
Web3.to_wei(0.88, "ether")
])

run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name)
run_test(contract_oeth_vault, data, backend, firmware, navigator, test_name, wallet_addr)
16 changes: 8 additions & 8 deletions tests/oeth/test_oeth_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"4626-vault"
)

def test_oeth_wrap(backend, firmware, navigator, test_name):
def test_oeth_wrap(backend, firmware, navigator, test_name, wallet_addr):
client = EthAppClient(backend)

with client.get_public_addr(display=False):
Expand All @@ -21,17 +21,17 @@ def test_oeth_wrap(backend, firmware, navigator, test_name):
addr
])

run_test(contract_woeth, data, backend, firmware, navigator, test_name)
run_test(contract_woeth, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_wrap_different_beneficiary(backend, firmware, navigator, test_name):
def test_oeth_wrap_different_beneficiary(backend, firmware, navigator, test_name, wallet_addr):
data = contract_woeth.encodeABI("deposit", [
Web3.to_wei(1, "ether"),
bytes.fromhex("000000000000000000000000000000000000dEaD")
])

run_test(contract_woeth, data, backend, firmware, navigator, test_name)
run_test(contract_woeth, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_unwrap(backend, firmware, navigator, test_name):
def test_oeth_unwrap(backend, firmware, navigator, test_name, wallet_addr):
client = EthAppClient(backend)

with client.get_public_addr(display=False):
Expand All @@ -44,13 +44,13 @@ def test_oeth_unwrap(backend, firmware, navigator, test_name):
addr
])

run_test(contract_woeth, data, backend, firmware, navigator, test_name)
run_test(contract_woeth, data, backend, firmware, navigator, test_name, wallet_addr)

def test_oeth_unwrap_different_beneficiary(backend, firmware, navigator, test_name):
def test_oeth_unwrap_different_beneficiary(backend, firmware, navigator, test_name, wallet_addr):
data = contract_woeth.encodeABI("redeem", [
Web3.to_wei(1, "ether"),
bytes.fromhex("000000000000000000000000000000000000dEaD"),
bytes.fromhex("000000000000000000000000000000000002dEaD")
])

run_test(contract_woeth, data, backend, firmware, navigator, test_name)
run_test(contract_woeth, data, backend, firmware, navigator, test_name, wallet_addr)
Loading
Loading