diff --git a/README.md b/README.md index a7f54b4..243f77d 100644 --- a/README.md +++ b/README.md @@ -1,135 +1,91 @@ -# Ledger Rust Near Application -![Rule enforcer](https://github.com/dj8yfo/app-near-rs/actions/workflows/guidelines_enforcer.yml/badge.svg) ![Build and tests](https://github.com/dj8yfo/app-near-rs/actions/workflows/build_and_functional_tests.yml/badge.svg) +## Successful cases -This is a Near application written in Rust which can be forked to start a new project for the Ledger Nano S/X/SP devices. +### Case 1 (1 transfer action, parsed after header review): -* Implements standard features (display address, transaction signature...), -* Has functional tests using [Ragger](https://github.com/LedgerHQ/ragger), -* Has CI workflows mandatory for app deployment in the Ledger store. - -### Links - -* 📚 [Developer's documentation](https://developers.ledger.com/)
-* 🗣️ [Ledger's Discord server](https://discord.gg/Ledger) - -## Quick start guide - -### With VS Code - -You can quickly setup a development environment on any platform (macOS, Linux or Windows) to build and test your application with [Ledger's VS Code extension](https://marketplace.visualstudio.com/items?itemName=LedgerHQ.ledger-dev-tools). - -By using Ledger's own developer tools [Docker image](https://github.com/LedgerHQ/ledger-app-builder/pkgs/container/ledger-app-builder%2Fledger-app-dev-tools), the extension allows you to **build** your apps with the latest SDK, **test** them on **Speculos** and **load** them on any supported device. - -* Install and run [Docker](https://www.docker.com/products/docker-desktop/). -* Make sure you have an X11 server running : - * On Ubuntu Linux, it should be running by default. - * On macOS, install and launch [XQuartz](https://www.xquartz.org/) (make sure to go to XQuartz > Preferences > Security and check "Allow client connections"). - * On Windows, install and launch [VcXsrv](https://sourceforge.net/projects/vcxsrv/) (make sure to configure it to disable access control). -* Install [VScode](https://code.visualstudio.com/download) and add [Ledger's extension](https://marketplace.visualstudio.com/items?itemName=LedgerHQ.ledger-dev-tools). -* Open a terminal and clone `app-near-rust` with `git clone git@github.com:dj8yfo/app-near-rs.git`. -* Open the `app-near-rust` folder with VSCode. -* Use Ledger extension's sidebar menu or open the tasks menu with `ctrl + shift + b` (`command + shift + b` on a Mac) to conveniently execute actions : - * **Build** the app for the device model of your choice with `Build`. - * **Test** your binary on the [Speculos emulator](https://github.com/LedgerHQ/speculos) with `Run with emulator`. - * You can also **run functional tests**, load the app on a physical device, and more. - -ℹ️ The terminal tab of VSCode will show you what commands the extension runs behind the scene. - -## Compilation and load - -If you do not wish to use the [VS Code extension](#with-vs-code), you can follow the following steps to setup a development environment on a host running a Debian based Linux distribution (such as Ubuntu). - -### Prerequisites - -* Install the [Rust language](https://www.rust-lang.org/) - -```bash -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -``` - -* Install Ledger Rust building tools dependencies - -```bash -# Clang compiler, GCC ARM cross-compiling toolchain -apt install clang gcc-arm-none-eabi gcc-multilib -# Rust nightly toolchain used to compile ledger devices binaries -rustup install nightly-2022-12-02 -# Install required component of the nightly toolchain -rustup component add rust-src --toolchain nightly-2022-12-02 -``` - -* Install [ledgerwallet](https://github.com/LedgerHQ/ledgerctl/) and [cargo-ledger](https://github.com/LedgerHQ/cargo-ledger) +For following transaction with [tested larger buffers](https://github.com/dj8yfo/app-near-rs/blob/master/src/parsing/types/transaction_prefix/mod.rs#L16-L17): ```bash -# Install ledgerwallet, a Python dependency of cargo-ledger to sideload binaries on Ledger devices -pip install ledgerwallet -# Install latest cargo-ledger from crates.io -cargo install cargo-ledger -# Setup the custom nightly Rust toolchain as default -rustup default nightly-2022-12-02 -# Run cargo-ledger command to install custom target files on the custom nightly toolchain -cargo ledger setup +[2024-01-09T18:14:52Z INFO sign_transaction::common] --- +[2024-01-09T18:14:52Z INFO sign_transaction::common] Transaction: +[2024-01-09T18:14:52Z INFO sign_transaction::common] Transaction { + signer_id: AccountId( + "1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.246.247.248.249.250.251.252.253.254.255.256.257.258.259.260.261.262.263.264.265.266.267.268.269.270.271.272.273.274.275.276.277.278.279.280.281.282.283.284.285.286.287.288.289.290.291.292.293.294.295.296.297.298.299.300.301.302.303.304.305.306.307.308.309.310.311.312.313.314.315.316.317.318.319.320.321.322.323.324.325.326.327.328.329.330.331.332.333.334.335.336.337.338.339.340.341.342.343.344.345.346.347.348.349.350.351.352.353.354.355.356.357.358.359.360.361.362.363.364.365.366.367.368.369.370.371.372.373.374.375.376.377.378.379.380.381.382.383.384.385.386.387.388.389.390.391.392.393.394.395.396.397.398.399.400\n", + ), + public_key: ed25519:9Lab2du3zZg5MrZPJCAd1fka7nHuP9Rgo643d8C8hGiJ, + nonce: 103595482000005, + receiver_id: AccountId( + "1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.246.247.248.249.250.251.252.253.254.255.256.257.258.259.260.261.262.263.264.265.266.267.268.269.270.271.272.273.274.275.276.277.278.279.280.281.282.283.284.285.286.287.288.289.290.291.292.293.294.295.296.297.298.299.300.301.302.303.304.305.306.307.308.309.310.311.312.313.314.315.316.317.318.319.320.321.322.323.324.325.326.327.328.329.330.331.332.333.334.335.336.337.338.339.340.341.342.343.344.345.346.347.348.349.350.351.352.353.354.355.356.357.358.359.360.361.362.363.364.365.366.367.368.369.370.371.372.373.374.375.376.377.378.379.380.381.382.383.384.385.386.387.388.389.390.391.392.393.394.395.396.397.398.399.400\n", + ), + block_hash: Cb3vKNiF3MUuVoqfjuEFCgSNPT79pbuVfXXd2RxDXc5E, + actions: [ + Transfer( + TransferAction { + deposit: 150000000000000000000000, + }, + ), + ], + } +[2024-01-09T18:14:52Z INFO sign_transaction::common] transaction byte array length: 3086 +[2024-01-09T18:14:52Z INFO sign_transaction::common] --- ``` -You are now ready to build the Near app for Ledger devices ! -### Building +![prelude](mds/imgs/case1/prelude.png) +![header](mds/imgs/case1/header_1.png) +![header](mds/imgs/case1/header_2.png) +![header](mds/imgs/case1/header_3.png) -Now that you have followed the [prerequisites](#prerequisites) guide, you can build the Near with the following command executed in the root directory of the app. +... -```bash -cargo ledger nanox build -``` +![header](mds/imgs/case1/header_4.png) +![header](mds/imgs/case1/header_5.png) +![header](mds/imgs/case1/header_6.png) -This command will build the app for the Nano X, but you can use any supported device (`nanos`, `nanox`, `nanosplus`) +... -### Loading +![header](mds/imgs/case1/header_7.png) +![header](mds/imgs/case1/header_8.png) +![header](mds/imgs/case1/header_9.png) +![header](mds/imgs/case1/header_10.png) +![header](mds/imgs/case1/header_11.png) +![header](mds/imgs/case1/action_1.png) +![header](mds/imgs/case1/action_2.png) +![header](mds/imgs/case1/action_3.png) +![header](mds/imgs/case1/action_4.png) +![header](mds/imgs/case1/action_5.png) -ℹ️ Your device must be connected, unlocked and the screen showing the dashboard (not inside an application). - -[cargo-ledger](https://github.com/LedgerHQ/cargo-ledger) also allows you to side load the binary with the following command line executed in the root directory of the Near app. - -```bash -cargo ledger build nanox --load -``` -As for the build command, you can replace `nanos` with `nanox` or `nanosplus`. +### Case 2 (1 MB size transaction): -## Test - -### Ragger functional tests - -This Near app comes with functional tests implemented with Ledger's [Ragger](https://github.com/LedgerHQ/ragger) test framework. - -* Install the tests requirements +1 MB size transaction flows through the device for around 7 minutes, if +the [chunk size](https://github.com/khorolets/near-ledger-rs/blob/main/src/lib.rs#L19) is increased twofold to `255`, +otherwise it takes twice as long. ```bash -pip install -r tests/requirements.txt -``` - -* Run the functional tests (here for Nano S Plus but available for any supported device once you have built the binaries) : - -```shell -mkdir -p build/nanos2/bin && cp target/nanosplus/release/app-near-rust build/nanos2/bin/app.elf -pytest tests/ --tb=short -v --device nanosp +[2024-01-03T17:44:31Z INFO sign_transaction::common] hex : 6d72c0332649f2f840dd9fb41c90f3e5ff582c6a7343e8b77b72f7df22a65615 +[2024-01-03T17:44:31Z INFO sign_transaction::common] base58 : ed25519:8NEvfU5Nn9TMAYjKXY2SjWdMkbU68BXkRs7JghYcnAWg +[2024-01-03T17:44:31Z INFO sign_transaction::common] --- +[2024-01-03T17:44:31Z INFO sign_transaction::common] --- +[2024-01-03T17:44:31Z INFO sign_transaction::common] Transaction: +[2024-01-03T17:44:31Z INFO sign_transaction::common] transaction byte array length: 1020213 +[2024-01-03T17:44:31Z INFO sign_transaction::common] --- +[2024-01-03T17:51:36Z INFO sign_transaction] received response (hex) : 18afc45d456de50578447a6b6fd19ef6d4f1b201727e04e59233fa1ce75c3e38146c30b188c5f7b260c232faa4b4a140dffb7abc86ec87f200c6f4a8d75f0c05 +[2024-01-03T17:51:36Z INFO sign_transaction::common] --- +[2024-01-03T17:51:36Z INFO sign_transaction::common] Signature: +[2024-01-03T17:51:36Z INFO sign_transaction::common] tx hash (hex) : 0b4f9b0852a3a51ae3cbd0c1502721878b36d561bf2e57ed8438ca738a624422 +[2024-01-03T17:51:36Z INFO sign_transaction::common] signature (hex) : 18AFC45D456DE50578447A6B6FD19EF6D4F1B201727E04E59233FA1CE75C3E38146C30B188C5F7B260C232FAA4B4A140DFFB7ABC86EC87F200C6F4A8D75F0C05 +[2024-01-03T17:51:36Z INFO sign_transaction::common] signature (base58) : ed25519:VdMG61q4a6Loxto5wkJSsXWQXhoGLbwMPSY6dnBwgvkJzSqqFcWWWroAMQAUkuPPk2ExgeLZPBFoMyoTCS29iCL +[2024-01-03T17:51:36Z INFO sign_transaction::common] --- ``` -### Emulator +## [Encountered issues/blockers](./mds/issues.md) -You can also run the app directly on the [Speculos emulator](https://github.com/LedgerHQ/speculos) +## [Platform support](./mds/platforms.md) -```bash -speculos --model nanox target/nanox/release/app-near-rust -``` +## [Binary sizes](./mds/binary_sizes.md) -## Continuous Integration +## [Memory layout](./mds/memory_layout.md) -The following workflows are executed in [GitHub Actions](https://github.com/features/actions) : +## [issues with `borsh` usage](./mds/borsh_usage.md) -* Ledger guidelines enforcer which verifies that an app is compliant with Ledger guidelines. The successful completion of this reusable workflow is a mandatory step for an app to be available on the Ledger application store. More information on the guidelines can be found in the repository [ledger-app-workflow](https://github.com/LedgerHQ/ledger-app-workflows) -* Compilation of the application for all supported devices in the [ledger-app-builder](https://github.com/LedgerHQ/ledger-app-builder) docker image -* End-to-end tests with the [Speculos](https://github.com/LedgerHQ/speculos) emulator and [ragger](https://github.com/LedgerHQ/ragger) (see [tests/](tests/)) -* Various lint checks : - * Source code lint checks with `cargo fmt` - * Python functional test code lint checks with `pylint` and `mypy` diff --git a/README.old.md b/README.old.md new file mode 100644 index 0000000..a7f54b4 --- /dev/null +++ b/README.old.md @@ -0,0 +1,135 @@ +# Ledger Rust Near Application + +![Rule enforcer](https://github.com/dj8yfo/app-near-rs/actions/workflows/guidelines_enforcer.yml/badge.svg) ![Build and tests](https://github.com/dj8yfo/app-near-rs/actions/workflows/build_and_functional_tests.yml/badge.svg) + +This is a Near application written in Rust which can be forked to start a new project for the Ledger Nano S/X/SP devices. + +* Implements standard features (display address, transaction signature...), +* Has functional tests using [Ragger](https://github.com/LedgerHQ/ragger), +* Has CI workflows mandatory for app deployment in the Ledger store. + +### Links + +* 📚 [Developer's documentation](https://developers.ledger.com/)
+* 🗣️ [Ledger's Discord server](https://discord.gg/Ledger) + +## Quick start guide + +### With VS Code + +You can quickly setup a development environment on any platform (macOS, Linux or Windows) to build and test your application with [Ledger's VS Code extension](https://marketplace.visualstudio.com/items?itemName=LedgerHQ.ledger-dev-tools). + +By using Ledger's own developer tools [Docker image](https://github.com/LedgerHQ/ledger-app-builder/pkgs/container/ledger-app-builder%2Fledger-app-dev-tools), the extension allows you to **build** your apps with the latest SDK, **test** them on **Speculos** and **load** them on any supported device. + +* Install and run [Docker](https://www.docker.com/products/docker-desktop/). +* Make sure you have an X11 server running : + * On Ubuntu Linux, it should be running by default. + * On macOS, install and launch [XQuartz](https://www.xquartz.org/) (make sure to go to XQuartz > Preferences > Security and check "Allow client connections"). + * On Windows, install and launch [VcXsrv](https://sourceforge.net/projects/vcxsrv/) (make sure to configure it to disable access control). +* Install [VScode](https://code.visualstudio.com/download) and add [Ledger's extension](https://marketplace.visualstudio.com/items?itemName=LedgerHQ.ledger-dev-tools). +* Open a terminal and clone `app-near-rust` with `git clone git@github.com:dj8yfo/app-near-rs.git`. +* Open the `app-near-rust` folder with VSCode. +* Use Ledger extension's sidebar menu or open the tasks menu with `ctrl + shift + b` (`command + shift + b` on a Mac) to conveniently execute actions : + * **Build** the app for the device model of your choice with `Build`. + * **Test** your binary on the [Speculos emulator](https://github.com/LedgerHQ/speculos) with `Run with emulator`. + * You can also **run functional tests**, load the app on a physical device, and more. + +ℹ️ The terminal tab of VSCode will show you what commands the extension runs behind the scene. + +## Compilation and load + +If you do not wish to use the [VS Code extension](#with-vs-code), you can follow the following steps to setup a development environment on a host running a Debian based Linux distribution (such as Ubuntu). + +### Prerequisites + +* Install the [Rust language](https://www.rust-lang.org/) + +```bash +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +``` + +* Install Ledger Rust building tools dependencies + +```bash +# Clang compiler, GCC ARM cross-compiling toolchain +apt install clang gcc-arm-none-eabi gcc-multilib +# Rust nightly toolchain used to compile ledger devices binaries +rustup install nightly-2022-12-02 +# Install required component of the nightly toolchain +rustup component add rust-src --toolchain nightly-2022-12-02 +``` + +* Install [ledgerwallet](https://github.com/LedgerHQ/ledgerctl/) and [cargo-ledger](https://github.com/LedgerHQ/cargo-ledger) + +```bash +# Install ledgerwallet, a Python dependency of cargo-ledger to sideload binaries on Ledger devices +pip install ledgerwallet +# Install latest cargo-ledger from crates.io +cargo install cargo-ledger +# Setup the custom nightly Rust toolchain as default +rustup default nightly-2022-12-02 +# Run cargo-ledger command to install custom target files on the custom nightly toolchain +cargo ledger setup +``` + +You are now ready to build the Near app for Ledger devices ! + +### Building + +Now that you have followed the [prerequisites](#prerequisites) guide, you can build the Near with the following command executed in the root directory of the app. + +```bash +cargo ledger nanox build +``` + +This command will build the app for the Nano X, but you can use any supported device (`nanos`, `nanox`, `nanosplus`) + +### Loading + +ℹ️ Your device must be connected, unlocked and the screen showing the dashboard (not inside an application). + +[cargo-ledger](https://github.com/LedgerHQ/cargo-ledger) also allows you to side load the binary with the following command line executed in the root directory of the Near app. + +```bash +cargo ledger build nanox --load +``` + +As for the build command, you can replace `nanos` with `nanox` or `nanosplus`. + +## Test + +### Ragger functional tests + +This Near app comes with functional tests implemented with Ledger's [Ragger](https://github.com/LedgerHQ/ragger) test framework. + +* Install the tests requirements + +```bash +pip install -r tests/requirements.txt +``` + +* Run the functional tests (here for Nano S Plus but available for any supported device once you have built the binaries) : + +```shell +mkdir -p build/nanos2/bin && cp target/nanosplus/release/app-near-rust build/nanos2/bin/app.elf +pytest tests/ --tb=short -v --device nanosp +``` + +### Emulator + +You can also run the app directly on the [Speculos emulator](https://github.com/LedgerHQ/speculos) + +```bash +speculos --model nanox target/nanox/release/app-near-rust +``` + +## Continuous Integration + +The following workflows are executed in [GitHub Actions](https://github.com/features/actions) : + +* Ledger guidelines enforcer which verifies that an app is compliant with Ledger guidelines. The successful completion of this reusable workflow is a mandatory step for an app to be available on the Ledger application store. More information on the guidelines can be found in the repository [ledger-app-workflow](https://github.com/LedgerHQ/ledger-app-workflows) +* Compilation of the application for all supported devices in the [ledger-app-builder](https://github.com/LedgerHQ/ledger-app-builder) docker image +* End-to-end tests with the [Speculos](https://github.com/LedgerHQ/speculos) emulator and [ragger](https://github.com/LedgerHQ/ragger) (see [tests/](tests/)) +* Various lint checks : + * Source code lint checks with `cargo fmt` + * Python functional test code lint checks with `pylint` and `mypy` diff --git a/mds/binary_sizes.md b/mds/binary_sizes.md new file mode 100644 index 0000000..9165dfd --- /dev/null +++ b/mds/binary_sizes.md @@ -0,0 +1,113 @@ +Judging from `app_nano*.json` files which are used by `ledgerctl install` command, +the relevant lines are `app.hex` files, but ... + + +more info on a specific Nanos will be checked with `ledgerctl meminfo`, +currently the device has gone into [brick/boot mode](https://support.ledger.com/hc/en-us/articles/4410408656273-Device-in-Booting-mode?support=true), +due to [issue](https://github.com/LedgerHQ/app-boilerplate-rust/issues/47) with debug instructions. + +# nanos + + +```bash + +> ledgerctl meminfo # before +Memory usage: +- System: 181.8KB (56.84%) +- Applications: 0.0B (0.00%) +- Available space: 138.0KB (43.16%) + +Installed apps: 0 (max: 30) + +> ledgerctl meminfo # after +Memory usage: +- System: 181.8KB (56.84%) +- Applications: 30.0KB (9.38%) +- Available space: 108.0KB (33.78%) + +Installed apps: 1 (max: 30) + +❯ du -B1 target/nanos/release/app* +86016 target/nanos/release/app.hex +151552 target/nanos/release/app-near-rust +65536 target/nanos/release/app-near-rust.apdu +4096 target/nanos/release/app-near-rust.d +``` + +vs + +```bash + +> ledgerctl meminfo # before +Memory usage: +- System: 181.8KB (56.84%) +- Applications: 0.0B (0.00%) +- Available space: 138.0KB (43.16%) + +Installed apps: 0 (max: 30) + +> ledgerctl meminfo # after +Memory usage: +- System: 181.8KB (56.84%) +- Applications: 24.0KB (7.51%) +- Available space: 114.0KB (35.65%) + +Installed apps: 1 (max: 30) + + +❯ du -B1 workdir/app-near/build/nanos/bin/* +53248 workdir/app-near/build/nanos/bin/app.apdu +77824 workdir/app-near/build/nanos/bin/app.elf +69632 workdir/app-near/build/nanos/bin/app.hex +4096 workdir/app-near/build/nanos/bin/app.sha256 +``` + +# nanosplus + +```bash +❯ du -B1 target/nanosplus/release/app* +90112 target/nanosplus/release/app.hex +155648 target/nanosplus/release/app-near-rust +69632 target/nanosplus/release/app-near-rust.apdu +4096 target/nanosplus/release/app-near-rust.d +``` + +vs + +```bash +❯ du -B1 workdir/app-near/build/nanos2/bin/* +69632 workdir/app-near/build/nanos2/bin/app.apdu +163840 workdir/app-near/build/nanos2/bin/app.elf +94208 workdir/app-near/build/nanos2/bin/app.hex +4096 workdir/app-near/build/nanos2/bin/app.sha256 +``` + +# nanox + +```bash +❯ du -B1 target/nanox/release/app* +114688 target/nanox/release/app.hex +266240 target/nanox/release/app-near-rust +86016 target/nanox/release/app-near-rust.apdu +4096 target/nanox/release/app-near-rust.d +``` + +vs + +```bash +❯ du -B1 workdir/app-near/build/nanox/bin/* +86016 workdir/app-near/build/nanox/bin/app.apdu +167936 workdir/app-near/build/nanox/bin/app.elf +114688 workdir/app-near/build/nanox/bin/app.hex +4096 workdir/app-near/build/nanox/bin/app.sha256 +``` + +![Storage pic](./imgs/ledger_storage.png) + + + + + + + + diff --git a/mds/borsh_usage.md b/mds/borsh_usage.md new file mode 100644 index 0000000..07f4e35 --- /dev/null +++ b/mds/borsh_usage.md @@ -0,0 +1,45 @@ +- [ ] extract everything about `alloc` crate into separate feature + - [ ] change `borsh/src/nostd_io.rs` or make 2 variants, depending on `alloc` feature + - [ ] make `BorshDeserialize` trait method `vec_from_reader` depending on `alloc` feature + - [ ] each usage of `io::Error::new` implies depending on `alloc` feature, there's around 50 occurencies of it in `borsh` + - [ ] no change required to `BorshSerialize` + - [ ] make `unstable__schema` feature imply `alloc` featue +```rust +// from +enum Repr { + Simple(ErrorKind), + Custom(Custom), +} + +impl Error { + pub fn new>(kind: ErrorKind, error: T) -> Error { + Self::_new(kind, error.into()) + } + + fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Custom { kind, error }), + } + } +} +``` + +```rust +// to +enum Repr { + Simple(ErrorKind), +} +impl Error { + +} +``` + +- [ ] one cannot `extern crate alloc` without defining allocator + - [ ] after + - [ ] adding stub allocator (allocator doing only panics) + - [ ] patching `cargo ledger build` with `"-Z", "build-std=core,alloc,proc_macro"` + - [ ] compiling fails, [similar issue](https://gitlab.com/jD91mZM2/no-std-compat/-/issues/6) + - [ ] probably `nanos`, `nanosplus`, `nanox` targets' json config has to be defined more correctly +- [ ] `pub fn deserialize_reader_in_place(&mut self, reader: &mut R) -> Result<()>` is more efficient for larger types + - [ ] than `fn deserialize_reader(rd: &mut R) -> Result` + - [ ] changing to `deserialize_reader_in_place` allowed to increase used buffers diff --git a/mds/imgs/case1/action_1.png b/mds/imgs/case1/action_1.png new file mode 100644 index 0000000..40dfaa3 Binary files /dev/null and b/mds/imgs/case1/action_1.png differ diff --git a/mds/imgs/case1/action_2.png b/mds/imgs/case1/action_2.png new file mode 100644 index 0000000..7ba3de3 Binary files /dev/null and b/mds/imgs/case1/action_2.png differ diff --git a/mds/imgs/case1/action_3.png b/mds/imgs/case1/action_3.png new file mode 100644 index 0000000..a491336 Binary files /dev/null and b/mds/imgs/case1/action_3.png differ diff --git a/mds/imgs/case1/action_4.png b/mds/imgs/case1/action_4.png new file mode 100644 index 0000000..fa2d42b Binary files /dev/null and b/mds/imgs/case1/action_4.png differ diff --git a/mds/imgs/case1/action_5.png b/mds/imgs/case1/action_5.png new file mode 100644 index 0000000..9ca04b8 Binary files /dev/null and b/mds/imgs/case1/action_5.png differ diff --git a/mds/imgs/case1/header_1.png b/mds/imgs/case1/header_1.png new file mode 100644 index 0000000..8d6f6de Binary files /dev/null and b/mds/imgs/case1/header_1.png differ diff --git a/mds/imgs/case1/header_10.png b/mds/imgs/case1/header_10.png new file mode 100644 index 0000000..36c412f Binary files /dev/null and b/mds/imgs/case1/header_10.png differ diff --git a/mds/imgs/case1/header_11.png b/mds/imgs/case1/header_11.png new file mode 100644 index 0000000..60482a7 Binary files /dev/null and b/mds/imgs/case1/header_11.png differ diff --git a/mds/imgs/case1/header_2.png b/mds/imgs/case1/header_2.png new file mode 100644 index 0000000..c9b422f Binary files /dev/null and b/mds/imgs/case1/header_2.png differ diff --git a/mds/imgs/case1/header_3.png b/mds/imgs/case1/header_3.png new file mode 100644 index 0000000..4e26bf4 Binary files /dev/null and b/mds/imgs/case1/header_3.png differ diff --git a/mds/imgs/case1/header_4.png b/mds/imgs/case1/header_4.png new file mode 100644 index 0000000..a9ffc6f Binary files /dev/null and b/mds/imgs/case1/header_4.png differ diff --git a/mds/imgs/case1/header_5.png b/mds/imgs/case1/header_5.png new file mode 100644 index 0000000..eb4c5fd Binary files /dev/null and b/mds/imgs/case1/header_5.png differ diff --git a/mds/imgs/case1/header_6.png b/mds/imgs/case1/header_6.png new file mode 100644 index 0000000..a74844b Binary files /dev/null and b/mds/imgs/case1/header_6.png differ diff --git a/mds/imgs/case1/header_7.png b/mds/imgs/case1/header_7.png new file mode 100644 index 0000000..f67df0e Binary files /dev/null and b/mds/imgs/case1/header_7.png differ diff --git a/mds/imgs/case1/header_8.png b/mds/imgs/case1/header_8.png new file mode 100644 index 0000000..486f607 Binary files /dev/null and b/mds/imgs/case1/header_8.png differ diff --git a/mds/imgs/case1/header_9.png b/mds/imgs/case1/header_9.png new file mode 100644 index 0000000..c29879c Binary files /dev/null and b/mds/imgs/case1/header_9.png differ diff --git a/mds/imgs/case1/prelude.png b/mds/imgs/case1/prelude.png new file mode 100644 index 0000000..b63b3e9 Binary files /dev/null and b/mds/imgs/case1/prelude.png differ diff --git a/mds/imgs/ledger_storage.png b/mds/imgs/ledger_storage.png new file mode 100644 index 0000000..2baae98 Binary files /dev/null and b/mds/imgs/ledger_storage.png differ diff --git a/mds/issues.md b/mds/issues.md new file mode 100644 index 0000000..b66b198 --- /dev/null +++ b/mds/issues.md @@ -0,0 +1,3 @@ + +1. [`ledger_device_sdk::testing::debug_print` causes hangs on nanos device](https://github.com/LedgerHQ/app-boilerplate-rust/issues/47) +2. [`Speculos` crashes and device app hangs on formatting with `core::fmt::Write`](https://github.com/LedgerHQ/ledger-device-rust-sdk/issues/113) diff --git a/mds/memory_layout.md b/mds/memory_layout.md new file mode 100644 index 0000000..940097f --- /dev/null +++ b/mds/memory_layout.md @@ -0,0 +1,8 @@ +The following data is probably somehow related to [pr](https://github.com/near/app-near/pull/11/files) + +[nanos layout](https://github.com/LedgerHQ/ledger-device-rust-sdk/blob/master/ledger_device_sdk/nanos_layout.ld) + +[nanosplus layout](https://github.com/LedgerHQ/ledger-device-rust-sdk/blob/master/ledger_device_sdk/nanosplus_layout.ld) + +[nanosx layout](https://github.com/LedgerHQ/ledger-device-rust-sdk/blob/master/ledger_device_sdk/nanox_layout.ld) + diff --git a/mds/platforms.md b/mds/platforms.md new file mode 100644 index 0000000..c5613b5 --- /dev/null +++ b/mds/platforms.md @@ -0,0 +1,8 @@ + +`ledger-device-rust-sdk` doesn't support `stax` [platform](https://github.com/LedgerHQ/app-near/blob/develop/ledger_app.toml#L4). + +The implementation is ongoing - [pr](https://github.com/LedgerHQ/ledger-device-rust-sdk/pull/109). + +It appears `stax` hasn't really been sold yet, it probably has only been preordered. + +