KomodoPlatform / komodo-wallet-mobile

KomodoWallet Mobile codebase
https://komodoplatform.com
MIT License
21 stars 31 forks source link

Please help building version 0.9.0 in a container #116

Open Giszmo opened 4 months ago

Giszmo commented 4 months ago

Hi team,

I'm trying to reproduce version 0.9.0 and while the version is not tagged, Emanuel identified a likely commit in #60. But ... my attempts to build the product in a reproducible way are so far not successful. Could you please help me build without Android Studio in a container?!

Update 2024-02-09: This app is source-available but despite various comments on the open issue 60 there is no reaction from the provider.

Emanuel has identified this commit as likely candidate for the current version v0.9.0 on Google Play. Let's see if we can compile it using the readme and what it points to ...

$ git clone https://github.com/KomodoPlatform/komodo-wallet-mobile
$ cd komodo-wallet-mobile/
$ podman run -it --rm -v$PWD:/mnt --workdir=/mnt android:latest
root@44f18b8963e9:/mnt# git checkout 60113f49959b74e3e70e3be937240538bda38549
root@44f18b8963e9:/mnt# apt update && apt full-upgrade -y
root@44f18b8963e9:/mnt# apt install jq curl coreutils
root@44f18b8963e9:/mnt# ./fetch_coins.sh 
root@44f18b8963e9:/mnt# git clone https://github.com/flutter/flutter.git $HOME/flutter
root@44f18b8963e9:/mnt# export PATH="$PATH:$HOME/flutter/bin"
root@44f18b8963e9:/mnt# cd ~/flutter
root@44f18b8963e9:/root/flutter# git fetch
root@44f18b8963e9:/root/flutter# git checkout tags/2.8.1
root@44f18b8963e9:/root/flutter# cd /mnt/
root@44f18b8963e9:/mnt# flutter build apk
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.
  /
📎
Downloading Gradle Wrapper...                                      984ms
/usr/bin/tar: gradle/wrapper/gradle-wrapper.properties: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradle/wrapper/gradle-wrapper.jar: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradle/wrapper: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradle: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradlew: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradlew.bat: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: NOTICE: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: Exiting with failure status due to previous errors
Downloading Gradle Wrapper...                                    1,114ms
/usr/bin/tar: gradle/wrapper/gradle-wrapper.properties: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradle/wrapper/gradle-wrapper.jar: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradle/wrapper: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradle: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradlew: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: gradlew.bat: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: NOTICE: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/usr/bin/tar: Exiting with failure status due to previous errors
Flutter could not download and/or extract
https://storage.googleapis.com/flutter_infra_release/gradle-wrapper/fd5c1f2c013565a3bea56ada6df9d2b8e96d56aa/gradle-wrapper.tgz. Ensure you have network
connectivity and all of the required dependencies listed at flutter.dev/setup.
The original exception was: ProcessException: The command failed
  Command: tar -xzf
  /root/flutter/bin/cache/downloads/storage.googleapis.com/flutter_infra_release/gradle-wrapper/fd5c1f2c013565a3bea56ada6df9d2b8e96d56aa/gradle-wrapper.tgz -C
  /root/flutter/bin/cache/artifacts/gradle_wrapper.
root@44f18b8963e9

and that's where we give up for now. The build instructions are geared towards IDE integration, explaining how to build the project with Android Studio while we need isolation in a docker container for example and automation via the command line.

CharlVS commented 4 months ago

@Giszmo Thanks for bringing this to my attention. I will make it a priority to resolve this.

We strive for top-notch developer experience (DevEx) at Komodo so thanks for sharing your feedback.

CharlVS commented 4 months ago

Please see below for the tagged 0.9.0 release. I'm looking into the reported issue about documenting CLI build process this week.

0.9.0 GitHub Release

Shourya742 commented 1 month ago

@CharlVS I need assistance with the CLI build process to reproduce the wallet build. Could you kindly help with this?

CharlVS commented 1 month ago

@Shourya742 please share your console output and any other information you can provide.

If you have Flutter setup, please also do flutter doctor -v in your terminal and share the output.

Shourya742 commented 1 month ago

@CharlVS I don't have the Flutter setup on my local machine; instead, I am trying to build the application using a container. I followed the commands provided in the Project Setup guide: https://github.com/KomodoPlatform/komodo-wallet-mobile/wiki/Project-Setup#build-and-run

Shourya742 commented 1 month ago

Hello @CharlVS I encountered an error while attempting to build the APK for our project using the Flutter command within a Docker environment. Below is the error output:

Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

Running Gradle task 'assembleRelease'...                        
Running Gradle task 'assembleRelease'...                           16.1s

Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

Running Gradle task 'assembleRelease'...                        
.dart_tool/flutter_build/generated_main.dart:13:8: Error: Error when reading '/root/.pub-cache/git/dargon2-d11f51cab560acf7644ebef402f1996b6f320365/dargon2_flutter/dargon2_flutter_mobile/lib/dargon2_flutter_mobile.dart': No such file or directory
import 'package:dargon2_flutter_mobile/dargon2_flutter_mobile.dart';
       ^
.dart_tool/flutter_build/generated_main.dart:17:8: Error: Error when reading '/root/.pub-cache/git/dargon2-d11f51cab560acf7644ebef402f1996b6f320365/dargon2_flutter/dargon2_flutter_mobile/lib/dargon2_flutter_mobile.dart': No such file or directory
import 'package:dargon2_flutter_mobile/dargon2_flutter_mobile.dart';
       ^
.dart_tool/flutter_build/generated_main.dart:14:8: Error: Error when reading '/root/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.12/lib/path_provider_android.dart': No such file or directory
import 'package:path_provider_android/path_provider_android.dart';
       ^
       ^
lib/model/addressbook_provider.dart:5:8: Error: Error when reading '/root/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.15/lib/shared_preferences.dart': No such file or directory
import 'package:shared_preferences/shared_preferences.dart';
       ^
lib/model/cex_provider.dart:9:8: Error: Error when reading '/root/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.15/lib/shared_preferences.dart': No such file or directory
import 'package:shared_preferences/shared_preferences.dart';
       ^
lib/model/feed_provider.dart:10:8: Error: Error when reading '/root/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.15/lib/shared_preferences.dart': No such file or directory
import 'package:shared_preferences/shared_preferences.dart';
       ^
lib/model/swap_provider.dart:8:8: Error: Error when reading '/root/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.15/lib/shared_preferences.dart': No such file or directory      
/sdks/flutter/packages/flutter/lib/src/widgets/container.dart:352:9: Error: Type 'Matrix4' not found.
  final Matrix4? transform;
        ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/implicit_animations.dart:166:34: Error: Type 'Matrix4' not found.
class Matrix4Tween extends Tween<Matrix4> {
                                 ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/implicit_animations.dart:172:18: Error: Type 'Matrix4' not found.
  Matrix4Tween({ Matrix4? begin, Matrix4? end }) : super(begin: begin, end: end);
                 ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/implicit_animations.dart:172:34: Error: Type 'Matrix4' not found.
  Matrix4Tween({ Matrix4? begin, Matrix4? end }) : super(begin: begin, end: end);
                                 ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/implicit_animations.dart:175:3: Error: Type 'Matrix4' not found.
  Matrix4 lerp(double t) {
  ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/implicit_animations.dart:688:9: Error: Type 'Matrix4' not found.
  final Matrix4? transform;
        ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/interactive_viewer.dart:23:80: Error: Type 'Quad' not found.
typedef InteractiveViewerWidgetBuilder = Widget Function(BuildContext context, Quad viewport);
                                                                               ^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/interactive_viewer.dart:360:10: Error: Type 'Vector3' not found.
  static Vector3 getNearestPointOnLine(Vector3 point, Vector3 l1, Vector3 l2) {
         ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/interactive_viewer.dart:360:40: Error: Type 'Vector3' not found.
  static Vector3 getNearestPointOnLine(Vector3 point, Vector3 l1, Vector3 l2) {
                                       ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/interactive_viewer.dart:360:55: Error: Type 'Vector3' not found.
  static Vector3 getNearestPointOnLine(Vector3 point, Vector3 l1, Vector3 l2) {
                                                      ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/interactive_viewer.dart:360:67: Error: Type 'Vector3' not found.
  static Vector3 getNearestPointOnLine(Vector3 point, Vector3 l1, Vector3 l2) {
                                                                  ^^^^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/interactive_viewer.dart:379:10: Error: Type 'Quad' not found.
  static Quad getAxisAlignedBoundingBox(Quad quad) {
         ^^^^
/sdks/flutter/packages/flutter/lib/src/widgets/interactive_viewer.dart:379:41: Error: Type 'Quad' not found.
  static Quad getAxisAlignedBoundingBox(Quad quad) {

    Rational newAmount;
    ^^^^^^^^
lib/model/swap_constructor_provider.dart:188:19: Error: The getter 'Rational' isn't defined for the class 'ConstructorProvider'.
 - 'ConstructorProvider' is from 'package:komodo_dex/model/swap_constructor_provider.dart' ('lib/model/swap_constructor_provider.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Rational'.
      newAmount = Rational.parse(newText);
                  ^^^^^^^^
lib/model/swap_constructor_provider.dart:207:5: Error: 'Rational' isn't a type.
    Rational newAmount;
    ^^^^^^^^
lib/model/swap_constructor_provider.dart:209:19: Error: The getter 'Rational' isn't defined for the class 'ConstructorProvider'.
 - 'ConstructorProvider' is from 'package:komodo_dex/model/swap_constructor_provider.dart' ('lib/model/swap_constructor_provider.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Rational'.
      newAmount = Rational.parse(newText);
                  ^^^^^^^^
lib/model/swap_constructor_provider.dart:229:5: Error: 'Rational' isn't a type.
    Rational amount;
    ^^^^^^^^
lib/model/swap_constructor_provider.dart:302:11: Error: 'Rational' isn't a type.
    final Rational price = _matchingOrder.action == Market.SELL
          ^^^^^^^^
lib/model/swap_constructor_provider.dart:305:11: Error: 'Rational' isn't a type.
    final Rational volume = _buyAmount;
          ^^^^^^^^
lib/model/swap_constructor_provider.dart:463:13: Error: 'Rational' isn't a type.
      final Rational minOrderVolume = _matchingOrder.minVolume;
            ^^^^^^^^
lib/model/swap_constructor_provider.dart:468:15: Error: 'Rational' isn't a type.
        final Rational price = _matchingOrder.action == Market.SELL
              ^^^^^^^^
lib/model/swap_constructor_provider.dart:471:15: Error: 'Rational' isn't a type.
        final Rational minSellVolume = minOrderVolume / price;
              ^^^^^^^^
lib/model/swap_provider.dart:150:3: Error: 'SharedPreferences' isn't a type.
  SharedPreferences _prefs;
                   ^^^^^^^^^^^^^^^^^
lib/screens/dex/trade/pro/create/receive/matching_bids_table.dart:285:11: Error: 'Rational' isn't a type.
    final Rational maxSellAmt = swapBloc.maxTakerVolume ??
          ^^^^^^^^
lib/screens/dex/trade/pro/create/receive/matching_bids_table.dart:286:9: Error: The getter 'Rational' isn't defined for the class '_MatchingBidsTableState'.
 - '_MatchingBidsTableState' is from 'package:komodo_dex/screens/dex/trade/pro/create/receive/matching_bids_table.dart' ('lib/screens/dex/trade/pro/create/receive/matching_bids_table.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Rational'.
        Rational.parse(swapBloc.sellCoinBalance.balance.balance.toString());
        ^^^^^^^^
lib/screens/dex/trade/pro/create/receive/bid_details_dialog.dart:56:36: Error: Undefined name 'SharedPreferences'.
                            (await SharedPreferences.getInstance()).setBool(
                                   ^^^^^^^^^^^^^^^^^

FAILURE: Build failed with an exception.

* Where:
Script '/sdks/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1070

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/sdks/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
Running Gradle task 'assembleRelease'...                           13.5s
Gradle task assembleRelease failed with exit code 1

STEPS TO reproduce: Dockerfile:

FROM cirrusci/flutter:2.8.0

ARG TAG

WORKDIR /mnt

RUN if [ -z "$TAG" ]; then echo "TAG argument must be provided" && exit 1; fi

RUN git clone --branch v$TAG https://github.com/KomodoPlatform/komodo-wallet-mobile.git;

WORKDIR /mnt/komodo-wallet-mobile

CMD ["flutter", "build", "apk"]

Commands to follow:

Build Image: docker build -t komodo --build-arg TAG=0.9.1 . Run container: docker run -it --rm komodo Please add the API builds for libmm2.a

CharlVS commented 1 month ago

@Shourya742 We're working on the Docker builds and will have that ready for you to test tomorrow.

Do you want us to include building the API (libmm2.a) binary when building the app or is it preferred to simply fetch from the public GitHub releases: https://github.com/KomodoPlatform/komodo-defi-framework/releases

Shourya742 commented 1 month ago

@CharlVS fetching makes more sense.. Thanks for this.

Giszmo commented 1 month ago

If the wallet is split into a library and frontend, both should be reproducible so ideally, yes, we would prefer to also reproduce the library for the purpose of WalletScrutiny.com. We do not build all widely used libraries but this one being controlled by the same provider is clearly of interest.

At some point in the future we might get a better grasp of reproducibility of dependencies to split this but for now, if you could please provide a script that builds all artifacts that would be nice.

CharlVS commented 1 month ago

@Giszmo, we have docker files for the API artefact here, so I can look into that for you.

For the current iteration, we've set up the containers to fetch from the GitHub releases. As of a few hours ago, they're finalised and ready for you and @Shourya742 to test out here. My concern for your review process of building the API artefact from the source is that the binary is built in a non-deterministic way. Hashes won't match and sometimes even vary in size slightly. NB that the container will only run successfully on an x86 machine. ARM support will be added in a future release.

If the above is a consideration and you want to compare it to the Play Store APK, please wait until we push a new build within the next week. Previous API artefact releases have had our OPSEC team build the artefacts locally, and then GitHub releases were built from a CI container.

Please let me know if you encounter any snags or if there's anything we can do to assist with the review process.

CharlVS commented 1 month ago

@Giszmo We're working on adding the artefact compilation to the container. JFYI in case you'd prefer to wait for that to be ready before your review.

Giszmo commented 1 month ago

I'll wait. Thanks for the effort.

CharlVS commented 4 weeks ago

@Giszmo, we've got the container set up with PR #147 to build our API artefact and mobile APK. This is an update to show there's progress, so I recommend waiting for it to be merged before proceeding. However, depending on our QA and OPSEC team's availability/priorities, that may still be at least a week or two.