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

Merging with onflow latest development branch #2

Merged
merged 47 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cc2333e
[auto] Add manifest
sgliner-ledger Mar 12, 2024
bccd8a6
Update ledger_app.toml
tdejoigny-ledger Mar 12, 2024
64dc30e
Update ledger_app.toml
tdejoigny-ledger Mar 12, 2024
5ac1290
Merge pull request #27 from LedgerHQ/tdj/fix_app_manifest
tdejoigny-ledger Mar 12, 2024
28a4625
Replace zxlib submodule with files
relatko Dec 31, 2023
168e450
Add rlp unit test to cmocka
relatko Jan 3, 2024
5a68a63
Add ledger_app.toml
relatko Jan 3, 2024
1e42ba2
Replace deprecated makefile parameter
relatko Jan 3, 2024
084c5df
Signing refactor to introduce message signing
relatko Jan 3, 2024
832fcb7
Add metadata parsing support
relatko Jan 3, 2024
b3becc4
Add script parser
relatko Jan 3, 2024
db8cd3b
Clang-format
relatko Jan 3, 2024
6792fbb
Failure to upload code coverage -> no CI failure
relatko Jan 3, 2024
94384f1
Add message signing (may not work yet)
relatko Jan 3, 2024
fa8537b
Merge with latest zxlib version
relatko Jan 4, 2024
3bc0b7f
Message signing with tests
relatko Jan 4, 2024
a1d429c
Merkle tree generator
relatko Jan 4, 2024
08f0934
Transaction signingusing merkle trees
relatko Jan 4, 2024
fe34ab8
Add tests merkle proof errors
relatko Jan 5, 2024
02f3c15
Arbitrary transaction signing
relatko Jan 5, 2024
b211994
Add manifest testcase generation
relatko Feb 8, 2024
eb4b8d2
Manifest speculos tests
relatko Feb 8, 2024
9ad215b
Improve logging
relatko Feb 26, 2024
0c32835
Remove script parsing code
relatko Feb 26, 2024
4b03837
Remove optional array
relatko Feb 26, 2024
cc09ce8
Arbitrary message signing simplification
relatko Mar 7, 2024
b9baf62
Support for reverted type value JSON order
relatko Mar 7, 2024
b4ccf3b
New manifest, including necessary testing changes
relatko Mar 8, 2024
454596a
String and enum types in metadata parsing
relatko Mar 15, 2024
48afd22
App supports string and enum types
relatko Mar 15, 2024
363cf7c
Process manifest with new types
relatko Mar 18, 2024
75f6857
Fix snapshots to latest containers
relatko Mar 21, 2024
0572431
Javascript layer
relatko Mar 24, 2024
dbc0511
NanoS/X/S+ show address from menu
relatko Apr 12, 2024
268bec7
STAX menu review address feature
relatko Apr 15, 2024
704dbc8
Bump version + fix related snapshots
relatko Apr 15, 2024
4e86887
Update APDU documentation
relatko Apr 17, 2024
4e5ab83
Remove duplicate (and unused) base58.* files
relatko Apr 17, 2024
eafad1c
Adjust max displayed value string on stax
relatko Apr 17, 2024
362fe04
Update manifest
relatko Apr 18, 2024
3e341c6
Shorten tx names and labels that were too long
relatko Apr 19, 2024
feebb05
Audit findings
relatko Jun 4, 2024
4025531
Remove unused old file
relatko Jun 5, 2024
0f7d03a
Improve docs
relatko Jun 5, 2024
2bf13a8
Audit related minor code improvements
relatko Jun 5, 2024
e10d732
Fix crypto call reurn value checks
relatko Jun 6, 2024
0c12067
Merge pull request #3 from vacuumlabs/audit_findings
relatko Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
22 changes: 22 additions & 0 deletions .github/workflows/js_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Javascript tests

on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- run: cd js && yarn install && yarn build && yarn test

2 changes: 1 addition & 1 deletion .github/workflows/misspellings_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
with:
builtin: clear,rare
check_filenames: true
skip: ./deps/jsmn/test/tests.c
skip: ./deps/jsmn/test/tests.c, ./transaction_metadata/manifest.mainnet.json, ./transaction_metadata/manifest.testnet.json,
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ jobs:
files: ./unit-tests/coverage.info
flags: unittests
name: codecov-app-flow
fail_ci_if_error: true
fail_ci_if_error: false
verbose: true
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ include $(BOLOS_SDK)/Makefile.defines
APPNAME = "Flow"

APPVERSION_M=0
APPVERSION_N=12
APPVERSION_N=13
APPVERSION_P=0
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

Expand Down Expand Up @@ -122,7 +122,15 @@ DEFINES += HAVE_BOLOS_APP_STACK_CANARY
DEFINES += LEDGER_SPECIFIC

ifeq ($(TARGET_NAME),TARGET_NANOS)
APP_STACK_SIZE:=2480
APP_STACK_MIN_SIZE:=2480
endif

########################################
# Unit tests and misc #
########################################

ifeq ($(DEBUG),1)
DEFINES += ZEMU_LOGGING
endif

#########################
Expand Down
93 changes: 88 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,85 @@ Please:
_Once the app is approved by Ledger, it will be available in their app store (Ledger Live).
The builds generated by this repository are for development purposes. THESE ARE UNVETTED DEVELOPMENT RELEASES._

## Quick start guide
## Quick start guide

#### Docker

Install and run [Docker](https://www.docker.com/products/docker-desktop/).

#### Compilation

We develop on Ubuntu. On different system slight adjustment of the commands may be necessary (see documentation below).

He recommended way to compile the app is:
1. Pull the latest docker container.
```shell
sudo docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
```
2. Start terminal within the container.
```shell
sudo docker run --rm -ti --user "$(id -u):$(id -g)" --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
```
3. Compile the app
```shell
make clean
make
make BOLOS_SDK=$NANOX_SDK
make BOLOS_SDK=$NANOSP_SDK
make BOLOS_SDK=$STAX_SDK
```

Stax app can be compiled in DEBUG mode for debugging purposes
```shell
make BOLOS_SDK=$STAX_SDK DEBUG=1
```
Note, that it is possible (although unlikely) for ledger to make a braking change in ledger-app-dev-tools:latest.

#### Tests

##### Speculos integration tests

These are the main test. These end to end test cover all app features.
To run them you should compile the app in ledger-app-dev-tools:latest container. And then (in container) run

```shell
pytest tests/ --tb=short -v --device nanos
pytest tests/ --tb=short -v --device nanox
pytest tests/ --tb=short -v --device nanosp
pytest tests/ --tb=short -v --device stax
```

Note that in case ledger-app-dev-tools:latest is updated there is a chance that slight changes in gui happen. In that case it is necessary to re-generate the snapshots, e.g.
```shell
pytest tests/ --tb=short -v --device nanos –golden_run
```
and review the changes in test/snapshots directory

##### Unit tests

As we want to test as close as possible to the production environment, the focus is on end to end integration test. However, certain complex parts of code, where test coverage with integration tests may be insufficient, are also tested using unit tests.

```shell
cd unit-tests/
cmake -Bbuild -H. && make -C build
CTEST_OUTPUT_ON_FAILURE=1 make -C build test
```

#### Scan build

We use scan build in ledger-app-dev-tools container (see Compilation section).

```shell
make clean
make scan-build
make scan-build BOLOS_SDK=$NANOX_SDK
make scan-build BOLOS_SDK=$NANOSP_SDK
make scan-build BOLOS_SDK=$STAX_SDK
```

## Further information

_Warning_: This is standard documentation for ledger app provided by ledger developers. As we do not use all the options, we do no guarantee that everything is up to date.

### General configuration

Expand Down Expand Up @@ -55,7 +133,7 @@ It will allow you, whether you are developing on macOS, Windows or Linux to quic

### With a terminal

#### Using the `ledger-app-dev-tools` docker container
#### Using the `ledger-app-dev-tools` docker container (recommended)

The [ledger-app-dev-tools](https://github.com/LedgerHQ/ledger-app-builder/pkgs/container/ledger-app-builder%2Fledger-app-dev-tools) docker image contains all the required tools and libraries to **build**, **test** and **load** an application.

Expand All @@ -67,7 +145,7 @@ sudo docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

You can then enter this development environment by executing the following command from the directory of the application `git` repository:

##### Linux (Ubuntu)
##### Linux (Ubuntu) (recommended)

```shell
sudo docker run --rm -ti --user "$(id -u):$(id -g)" --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
Expand Down Expand Up @@ -116,7 +194,7 @@ Setup a compilation environment by following the [shell with docker approach](#w
From inside the container, use the following command to build the app :

```shell
make DEBUG=1 # compile optionally with PRINTF
make
```

You can choose which device to compile and load for by setting the `BOLOS_SDK` environment variable to the following values :
Expand All @@ -126,6 +204,11 @@ You can choose which device to compile and load for by setting the `BOLOS_SDK` e
- `BOLOS_SDK=$NANOSP_SDK`
- `BOLOS_SDK=$STAX_SDK`

For Stax device you can compile
```shell
make BOLOS_SDK=$STAX_SDK DEBUG=1 # compile optionally with PRINTF
```

### Loading on a physical device

This step will vary slightly depending on your platform.
Expand Down Expand Up @@ -175,7 +258,7 @@ python3 -m ledgerblue.runScript --scp --fileName bin/app.apdu --elfFile bin/app.

The flow app comes with functional tests implemented with Ledger's [Ragger](https://github.com/LedgerHQ/ragger) test framework.

### Linux (Ubuntu)
### Linux (Ubuntu) (recommended)

On Linux, you can use [Ledger's VS Code extension](#with-vscode) to run the tests. If you prefer not to, open a terminal and follow the steps below.

Expand Down
1 change: 0 additions & 1 deletion deps/ledger-zxlib
Submodule ledger-zxlib deleted from ca7780
16 changes: 16 additions & 0 deletions deps/ledger-zxlib/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# top-most EditorConfig file
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true

[*.{c,h,cpp,hpp}]
indent_style = space
indent_size = 4

[*.{yml,sh}]
indent_style = space
indent_size = 2
59 changes: 59 additions & 0 deletions deps/ledger-zxlib/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Main workflow"
on: push

jobs:
configure:
runs-on: ubuntu-latest
outputs:
uid_gid: ${{ steps.get-user.outputs.uid_gid }}
steps:
- id: get-user
run: echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT

build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- run: cmake -DCMAKE_BUILD_TYPE=Debug . && make

check_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
exists: ${{ steps.get-version.outputs.exists }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- id: get-version
name: Get zxlib version
run: echo "version=$(./scripts/get_version.sh)" >> $GITHUB_OUTPUT
- id: tag-exists
name: Check if version exists
run: |
if git rev-parse ${{ steps.get-version.outputs.version }} >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Fail if tag exists
if: ${{ steps.tag-exists.outputs.exists == 'true' }}
run: exit 1

tag:
runs-on: ubuntu-latest
needs:
- build
- check_version
if: ${{ needs.check_version.outputs.exists != 'true' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.check_version.outputs.version }}
4 changes: 4 additions & 0 deletions deps/ledger-zxlib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

\.idea/
\.vscode/
cmake-build-debug/
57 changes: 57 additions & 0 deletions deps/ledger-zxlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#*******************************************************************************
#* (c) 2018 Zondax GmbH
#*
#* Licensed under the Apache License, Version 2.0 (the "License");
#* you may not use this file except in compliance with the License.
#* You may obtain a copy of the License at
#*
#* http://www.apache.org/licenses/LICENSE-2.0
#*
#* Unless required by applicable law or agreed to in writing, software
#* distributed under the License is distributed on an "AS IS" BASIS,
#* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#* See the License for the specific language governing permissions and
#* limitations under the License.
#********************************************************************************
cmake_minimum_required(VERSION 3.0)
project(ledger-zxlib)

set(CMAKE_CXX_STANDARD 11)

add_subdirectory(cmake/gtest)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
)

###############

file(GLOB_RECURSE ZXLIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
)

file(GLOB_RECURSE TESTS_SRC
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp
)

###############
set(BUILD_TESTS OFF CACHE BOOL "Enables tests")

add_library(zxlib STATIC ${ZXLIB_SRC})
target_include_directories(zxlib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)

enable_testing()

add_executable(zxlib_tests
${TESTS_SRC}
)

target_include_directories(zxlib_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${gtest_SOURCE_DIR}/include
${gmock_SOURCE_DIR}/include
)

target_link_libraries(zxlib_tests gtest_main zxlib)

add_test(ZXLIB_TESTS zxlib_tests)
Loading
Loading