Tribler / tribler

Privacy enhanced BitTorrent client with P2P content discovery
https://www.tribler.org
GNU General Public License v3.0
4.74k stars 445 forks source link

Bounty payout voting and payment execution - self-evolving AI-DAO #5986

Open synctext opened 3 years ago

synctext commented 3 years ago

Master course on Blockchain Engineering project 2021

TEAM P3: Bounty payout voting and payment execution Your team ensures people get paid for evolution of features. Use muti-sig wallet and quorum-based voting to create real-world Bitcoin payouts. Sync the vote progress with others, visualise as votes come in (approve or reject) and display the undecided votes. Any developer can contribute code to the DAO and get paid. It disconnects the DAO from any bank, government, and legal system. Help create a global economy that is hyper-efficient, fair, honest, and digital. prior work

General Description - self-evolving AI-DAO (https://github.com/Tribler/tribler/issues/5944)

Student from Delft have created a blockchain-based alternative to Spotify. Completely decentralised. Uses Bittorrent for streaming, Bitcoin for payments to artists, Trustchain with IPv8 for music discovery and IPv8 for app-to-app connectivity. With multiple teams the aim is to take this code to the next level: self-evolution.

A total of 4 students teams (4-5 students in each team) will work together on a cutting-edge scientific problem: how to create a software system which can be expanded in real-time and increasingly become more 'intelligent'. Build upon the existing open source app by TUDelft on the Android Play store using blockchain technology: the Superapp. You will help transform essential parts of the music industry and replace them with open source software. Current code:

GIF: Browsing and streaming music with Bittorrent
GIF: Sending money to artists using Bitcoin

DAO - organisations in software

To make a "self-evolving" app we use the DAO concept. What is a DAO? Within the coming decades the future of jobs, employment and the nature of the firm will change profoundly. Automation, AI, and robots will replace many of today's jobs. A new type of company is a company without any employees, without any machines or physical infrastructure. A Decentralized Autonomous Organizations, DAO, only exists in software. It goes beyond smart contracts, it is a complete company inside software. DAO development is still in the experimental stage. Background reading. Very optimistic view on DAO, official US review of DAO by Securities and Exchange Commission.

Within this master course you can create your very own autonomous organisation, the AI-DAO. Learn to engineer a decentralised autonomous organisation, use the existing tools, and understand the security risks. The aim is to alter the nature of the firm in the Internet age, see the Nobel prize winning theory. Production cost become essentially cost-free. An organisation which exists purely in cyberspace. The AI-DAO is designed to be the first sustainable DAO. How can we empower leaderless organizations? How can it earn money from manipulating bits?

Scientific challenge: Self-evolving

A key step in an autonomous system is that it can evolve independently. This enables growth and evolution independently of any central organisation, sponsoring government, or tribe of volunteers.

You will collectively solve the problem of paying somebody to make new features in open systems which are fully decentralised. This goes further then paying somebody Bitcoins to create a new version. Decentralised technology is very robust to failures, manipulation, faults, and courtcases. For instance, The Internet itself is almost impossible to shutdown so is the "Tor darknet". With other teams you will address a key drawback of decentralised technology: difficult to update, nearly impossible to evolve, and lacks incentives to develop new features.

dApp ecosystem

"Distributed Applications" are a distributed way of running code. You will help develop an ecosystem of "global code". Code is running atop a blockchain and peer-to-peer (P2P) network that acts as a kind of operating system. This provides security, resilience, privacy, and novel features. This is related to smart contracts, but has no slow single virtual machine (all discussed in the online classes material). Background material, read FBASE trustworthy code execution

PNG: difference between cloud and decentralised Apps
synctext commented 3 years ago
StevenL98 commented 3 years ago

You have to clone the repository as follows: git clone --recurse-submodules <repo-url> If the cloning of the submodule of kotlin-ipv8 fails, click the repository link and clone it separately within the project that is successfully cloned. The folder should look as follows:

trustchain-superapp
│   README.md
│   file001    
│
└───kotlin-ipv8
│   │   file011
│   │   file012
│   
└───folder2
    │   file021
    │   file022
StevenL98 commented 3 years ago

sync_gif ) Showing the sync button and the votes below each music album

synctext commented 3 years ago

Progress in Week 3.3 of this 10 week course:

StevenL98 commented 3 years ago
synctext commented 3 years ago

Impressive GUI!! Each bounty payout could be in simple MusicDAO style, like: "Pay 50mBTC from our common funds to artist named "L$D"? please dive into: https://github.com/bitcoin/bitcoin/issues/21278#issuecomment-785742678 Background reading, published yesterday: https://bitcoinmagazine.com/articles/lottrue-or-lotfalse-this-is-the-last-hurdle-before-taproot-activation

StefanWeegink commented 3 years ago

Hey! @RFHuisman and me have just finished implementing a working version of transactions. Currently still parts are hardcoded like public keys but as you can see we have already linked it to the UI, making it easier to test. The video bellow shows how our starting balance is 9.99 btc and then a transaction of 1btc is proposed. This transaction is approved by both users and is then executed and, thus, our balance has updated to 8.99 btc

https://user-images.githubusercontent.com/33690979/109689630-c91e3900-7b85-11eb-8a00-1bfea7e98839.mp4

RFHuisman commented 3 years ago

Hi! Taproot meets the requirements that you want once it is activated on the Bitcoin network. Details about the functionalities and confirming that it meets the requirements can be found here and here.

synctext commented 3 years ago

Taproot on Android: https://github.com/Tribler/tribler/issues/5996#issuecomment-787834532

CallumH2410 commented 3 years ago

Screenshot 2021-03-03 at 14 44 19

CallumH2410 commented 3 years ago

Screenshot 2021-03-03 at 16 20 13

synctext commented 3 years ago

Great progress! Three directions coming together as course goal:

Testnet: https://twitter.com/groestlcointeam/status/1340240253202948097?lang=en

StevenL98 commented 3 years ago

I can not start the Gradle daemon when my Mobile Hotspot of my laptop is running. At my parents, I have to because the WiFi is terrible there. It is a known bug mentioned in this issue. If you have an idea on how to fix this, please let me know.

xoriole commented 3 years ago

@StevenL98 Reading the issue thread, maybe you could try downgrading to a working version.

synctext commented 3 years ago
RFHuisman commented 3 years ago

Here are some screenshots showing bitcoind, bench_bitcoin and test_bitcoin, compiled from the latest master branch, successfully running on an Android emulator. I will post a guide later this/next week describing the setup I used and the steps that I took to compile it.

bitcoind android-bitcoin-screenshot6 android-bitcoin-screenshot7

bench_bitcoin android-bitcoin-screenshot4

test_bitcoin android-bitcoin-screenshot9

thversfelt commented 3 years ago

Hi, this is Thijs from Liquidity Pool group 1. We have also been looking into Taproot for our BTC part of the liquidity pool, and would really appreciate a guide for getting it to work on Android. Cheers!

RFHuisman commented 3 years ago

WIP: Guide for compiling Bitcoin Core on Android

Please contact me on my mail r.f.huisman@student.tudelft.nl if you have questions or are experiencing issues so I can adjust the guide.

NOTE: I used Ubuntu 20.04 LTS when writing and testing this guide. Other Ubuntu versions or Linux distributions probably work as well, but verify this on your own.

  1. Clone https://github.com/bitcoin/bitcoin locally.
  2. Install Android SDK version 28. More recent ones probably work as well, but I did not test that. You can use Android Studio to install the right SDK.
  3. Download the NDK revision 20b here https://developer.android.com/ndk/downloads/older_releases. Other versions did not work for me, but you might be able to figure out how to use later versions as well.
  4. Make sure to unzip and place the contents of the NDK in the SDK folder in the subfolder ndk-bundle.
  5. Follow this guide to install required dependencies when compiling. For Ubuntu, use this one https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md#linux-distribution-specific-instructions. Also make sure you have these dependencies installed for cross compiling https://github.com/bitcoin/bitcoin/tree/master/depends#for-linux-including-i386-arm-cross-compilation.
  6. cd in your terminal to the depends folder.
  7. In this folder, run the following command: sudo make HOST=x86_64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/home/rick/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin ANDROID_SDK=/home/rick/Android/Sdk/ ANDROID_NDK=/home/rick/Android/Sdk/ndk-bundle/

NOTE:

  1. Now wait to build depends (this takes some time). Make sure there are no errors before continuing.
  2. cd back to the bitcoin core folder.
  3. Run sudo ./autogen.sh
  4. Run the following command: sudo ./configure --prefix=/home/rick/Documents/bitcoin/depends/x86_64-linux-android/. Make sure the folder name is the same as the architecture you chose to compile before and that the path is correct for your computer.
  5. Now run sudo make -i LDFLAGS="-static-libstdc++". The -i flag ignores errors during compilation. There are certain files in the folder test/fuzz that give errors when compiling and I did not bother fixing them, since they are not needed to run or compile bitcoin core. In addition, LDFLAGS makes sure that you do not get a CANNOT LINK EXECUTABLE "./bitcoind": library "libc++_shared.so" not found error when trying to run the binary on your device.
  6. Wait for all the binaries to be built. Run file src/bitcoind and make sure it matches the architecture you compiled for and is runnable on your device.

NOTE: Next steps assume you are running an emulator, but the steps should be fairly similar when you are running on a physical device. Make sure to adjust the commands and the setup so that it works. Google is your friend here.

  1. Download the correct emulator in Android Studio. Make sure that it has the correct architecture that you compiled Bitcoin Core with (for me x86-64), that it runs the right Android version (for me 28) and that the device doesn't contain the Play Store. This is needed since we need to root the device. You can check this by going to the AVD Manager in Android Studio and it should say Google APIs in the Target column instead of Google Play.
  2. Start the emulator and open a new terminal. Wait until the emulator shows the home screen.
  3. Run adb devices to make sure the device is up and running and connected to adb. You probably need to install adb if you haven't before.
  4. Run adb root to root the device.
  5. Run adb push src/bitcoind /data/local/tmp to upload the bitcoind binary to the device in /data/local/tmp.
  6. Run adb shell and then run cd /data/local/tmp.
  7. To quickly test if we can run bitcoind, run mkdir .bitcoin and then ./bitcoind -datadir=.bitcoin. You can also upload other binaries that we compiled (like test-bitcoin or bench_bitcoin) and run them to test if it works.
  8. If you did not encounter any errors during the steps above and can run the binaries, then congratulations, you successfully compiled Bitcoin Core for Android.

I hope this guide was helpful. If you are stuck at a certain step or encounter other issues, please reach out to me via my mail (see the beginning of the guide) and I will see if I can help you further and potentially update the guide.

RFHuisman commented 3 years ago

@thversfelt Please check out the guide above and let me know if it works for you.

StefanWeegink commented 3 years ago

WIP: Guide for compiling Bitcoin Core on Android

Please contact me on my mail r.f.huisman@student.tudelft.nl if you have questions or are experiencing issues so I can adjust the guide.

NOTE: I used Ubuntu 20.04 LTS when writing and testing this guide. Other Ubuntu versions or Linux distributions probably work as well, but verify this on your own.

1. Clone https://github.com/bitcoin/bitcoin locally.

2. Install Android SDK version 28. More recent ones probably work as well, but I did not test that. You can use Android Studio to install the right SDK.

3. Download the NDK revision 20b here https://developer.android.com/ndk/downloads/older_releases. Other versions did not work for me, but you might be able to figure out how to use later versions as well.

4. Make sure to unzip and place the contents of the NDK in the SDK folder in the subfolder `ndk-bundle`.

5. Follow this guide to install required dependencies when compiling. For Ubuntu, use this one https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md#linux-distribution-specific-instructions. Also make sure you have these dependencies installed for cross compiling https://github.com/bitcoin/bitcoin/tree/master/depends#for-linux-including-i386-arm-cross-compilation.

6. `cd` in your terminal to the `depends` folder.

7. In this folder, run the following command: `sudo make HOST=x86_64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/home/rick/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin ANDROID_SDK=/home/rick/Android/Sdk/ ANDROID_NDK=/home/rick/Android/Sdk/ndk-bundle/`

NOTE:

* In the command above, HOST specifies the architecture that you are running Android on. For a physical device, this could be `aarch64-linux-android`, but I used an emulator, so we need to compile for the `x86_64-linux-android` architecture. Make sure to change this variable to the architecture you are running on your device.

* ANDROID_API_LEVEL is 28 in my case. Make sure this version is the same as the SDK you installed.

* Make sure the paths for `ANDROID_TOOLCHAIN_BIN`, `ANDROID_SDK` and `ANDROID_NDK` are correct on your computer.

1. Now wait to build depends (this takes some time). Make sure there are no errors before continuing.

2. `cd` back to the bitcoin core folder.

3. Run `sudo ./autogen.sh`

4. Run the following command: `sudo ./configure --prefix=/home/rick/Documents/bitcoin/depends/x86_64-linux-android/`. Make sure the folder name is the same as the architecture you chose to compile before and that the path is correct for your computer.

5. Now run `sudo make -i LDFLAGS="-static-libstdc++"`. The `-i` flag ignores errors during compilation. There are certain files in the folder `test/fuzz` that give errors when compiling and I did not bother fixing them, since they are not needed to run or compile bitcoin core. In addition, `LDFLAGS` makes sure that you do not get a `CANNOT LINK EXECUTABLE "./bitcoind": library "libc++_shared.so" not found` error when trying to run the binary on your device.

6. Wait for all the binaries to be built. Run `file src/bitcoind` and make sure it matches the architecture you compiled for and is runnable on your device.

NOTE: Next steps assume you are running an emulator, but the steps should be fairly similar when you are running on a physical device. Make sure to adjust the commands and the setup so that it works. Google is your friend here.

1. Download the correct emulator in Android Studio. Make sure that it has the correct architecture that you compiled Bitcoin Core with (for me x86-64), that it runs the right Android version (for me 28) and that the device doesn't contain the Play Store. This is needed since we need to root the device. You can check this by going to the AVD Manager in Android Studio and it should say Google APIs in the Target column instead of Google Play.

2. Start the emulator and open a new terminal. Wait until the emulator shows the home screen.

3. Run `adb devices` to make sure the device is up and running and connected to adb. You probably need to install adb if you haven't before.

4. Run `adb root` to root the device.

5. Run `adb push src/bitcoind /data/local/tmp` to upload the `bitcoind` binary to the device in `/data/local/tmp`.

6. Run `adb shell` and then run `cd /data/local/tmp`.

7. To quickly test if we can run `bitcoind`, run `mkdir .bitcoin` and then `./bitcoind -datadir=.bitcoin`. You can also upload other binaries that we compiled (like `test-bitcoin` or `bench_bitcoin`) and run them to test if it works.

8. If you did not encounter any errors during the steps above and can run the binaries, then congratulations, you successfully compiled Bitcoin Core for Android.

I hope this guide was helpful. If you are stuck at a certain step or encounter other issues, please reach out to me via my mail (see the beginning of the guide) and I will see if I can help you further and potentially update the guide.

I will test this tomorrow on a ubuntu 20.04.2 LTS server and run the emulator on windows (@RFHuisman ran it on ubuntu):

Tested it and got quite far except my server keeps crashing due to kernal error (unrelated to this). Some additions to @RFHuisman guide would be how to install the sdk/ndk without android studio:

step 2 $ wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip $ unzip commandlinetools-linux-6858069_latest.zip $ cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-28"

NOTE I had the following error: Error: Could not find or load main class java.se.ee to fix:

change java to 8 (in 11 they removed the java.se.ee class) and adjust default java version (verify using java -version)

If there are still errors you can try this or google the error:

$ unset JAVA_OPTS $ ./sdkmanager --licenses

step 3 & 4 $ wget https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip $ unzip android-ndk-r20b-linux-x86_64.zip

step 6 depends is in the bitcoin folder if you are looking for it

thversfelt commented 3 years ago

@thversfelt Please check out the guide above and let me know if it works for you.

Thank you for the comprehensive guide, we'll let you know.

StevenL98 commented 3 years ago
RFHuisman commented 3 years ago

https://en.bitcoin.it/wiki/Signet

synctext commented 3 years ago
StevenL98 commented 3 years ago

In this sprint we:

synctext commented 3 years ago

ToDo for final grading: PR accepted, Readme 1 & 2, and running .APK (readme, document stuff like the three Multi-Sig methods, library version, mining server Python scripts, unreviewed academic sig sharing paper, Taproot status, need for code refactoring, etc. ) Twitter-love animated .GIF of a working DAO for promotional purposes :rocket: 7 April meet: please have a .APK ready for testing n-out-of-n with all meeting members.

synctext commented 3 years ago

Extension beyond Q3 for beating Taproot into submission. Its proven hard to get fully working :hammer: Invite for 2nd edition of our workshop in Canada on 6-10 December 2021 with a scientific write-up of your DAO: https://middleware-conf.github.io/2021// https://dicg2020.github.io/ (small print requires performance evaluation graphs and paper acceptance) Because money is critical infrastructure, please do some burn-in testing and other Quality Assurance.

synctext commented 3 years ago

For readme, show the system architecture in 1 picture: taproot.tudelft server, regtest, BicoinJ library, rpc calls, regtest server, trustchain, voting system, negative vote spreading, etc.

StevenL98 commented 3 years ago

We sent the .apk file via mail, it can also be downloaded via this link. We will finish the readme and pull request before tomorrow.

See here our result video

https://user-images.githubusercontent.com/23526224/116259903-85efd900-a776-11eb-93b1-384936d215c4.mp4

RFHuisman commented 3 years ago

PR is ready: https://github.com/Tribler/trustchain-superapp/pull/70. It contains all of our code and documentation now

StevenL98 commented 3 years ago

The final .apk file can be downloaded here! Note, it will expire in 1 week (31-05-2021)