Code Monkey home page Code Monkey logo

blockchain-otc-dapp's Introduction

Blockchain OTC Market - Backend and web client

Setup Backend

Requirements

The following node packages or their dependencies uses native libraries:

Please take care for the dependencies of the build tool node-gyp.

Configuration

Parity

See Configuring Parity for the complete documentation.

Backend

See ./backend/config/defaults.json for the default configuration and define your custom configuration in ./config.json.

Additional resources

Development Mode

# install dependencies
$ npm install

# run setup for initial user, wallet and contracts (will skip for already existing ones)
$ npm run setup

# start server with hot reload at localhost:3000 (default configuration)
$ npm run dev

Production Mode

# install dependencies
$ NODE_ENV=production npm install

# run setup for initial user, wallet and contracts (will skip for already existing ones)
$ NODE_ENV=production npm run setup

# start server for production at localhost:3000 (default configuration)
$ NODE_ENV=production npm run start

Setup Client

See Blockchain OTC Market - Client

Initial Login

Credentials for the admin user created during setup:

Username: admin
Password: insecure!password

The password should be changed after login.

Process to setup a trading scenario

Initial user admin (above) has to:

  • distribute Euro token to existing other users who have to sign up themselves (via client user interface).
  • release Asset token for trading (via client user interface).

Users with Euro token can then buy Asset token, users with Asset token can sell them for Euro token.

blockchain-otc-dapp's People

Contributors

drmartinberger avatar karstengresch avatar siamaksade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

blockchain-otc-dapp's Issues

OpenShift: "The backend is currently not available!" though all pods are up

Environment

Tested with OpenShift version 3.11 on learn.openshift.com as well as with 4.1 on RHPDS and 4.1.14 locally (CodeReady containers).

Problem description

Instantiated the blockchain environment with deploy.sh as per the OpenShift README file

Though the parity, blockchain-app-mongodb, blockchain-app-backend, and blockchain-app-client pods start and the OTC client can be reached successfully, entering the credentials "admin/insecure!password" result in the error message:

"The backend is currently not available!"

Backend terminal log:

Environment: 
	DEV_MODE=false
	NODE_ENV=production
	DEBUG_PORT=5858
Launching via npm...
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info lifecycle [email protected]~prestart: [email protected]
npm info lifecycle [email protected]~start: [email protected]

> [email protected] start /opt/app-root/src
> node backend/setup && node backend/index

Mongoose: users.ensureIndex({ username: 1 }, { unique: true, background: true })
Mongoose: users.count({ isAdmin: true }, {})
Mongoose: users.ensureIndex({ wallet: 1 }, { unique: true, partialFilterExpression: { wallet: { '$type': 'string' } }, background: true })

Expected Behavior

Login and further setup is possible.

Discussion

A workaround in the local instance was to set the desired replica amount to 0 for the pods blockchain-app-mongodb, blockchain-app-backend, and blockchain-app-client and then set the amount up to 1 again, with a startup buffer of ~5 minutes each.
However, this workaround couldn't be successfully applied to the web hosted environments.

If a known workaround exists, it should be documented.

OpenShift: parity image reference (v1.9.6) broken

For documentation mainly (not pressure ;):

When deploying the app on OpenShift as described in https://github.com/itp-world/blockchain-otc-dapp/blob/master/openshift/README.md, the application cannot be started as the parity image isn't available anymore on DockerHub.

If you try to deploy the image, you get the error message:

An error occurred while starting the deployment.
Reason: cannot trigger a deployment for "parity" because it contains unresolved images

Expected behavior: Parity image gets pulled and pod started.

Client Not Getting Up: "This relative module was not found:   | * ./src/main.js in multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js"

For - ongoing - documentation purposes...

Problem

When following the documentation under openshift/README.md, i.e. creating an OpenShift project and installing parity, client and server as so...

oc new-project demo

oc create -f blockchain-app-template.yml
oc create -f parity-template.yml

oc new-app blockchain-app
oc new-app parity

... the pods come up, but the client app is not available (TBD, perhaps @siamaksade or @LutzLange : correct health checks needed.).

Pod log reports a problem with webpack:

Environment:
--
  | DEV_MODE=false
  | NODE_ENV=production
  | DEBUG_PORT=5858
  | Launching via npm...
  | npm info it worked if it ends with ok
  | npm info using [email protected]
  | npm info using [email protected]
  | npm info lifecycle [email protected]~prestart: [email protected]
  | npm info lifecycle [email protected]~start: [email protected]
  | > [email protected] start /opt/app-root/src
  | > npm run dev
  | npm info it worked if it ends with ok
  | npm info using [email protected]
  | npm info using [email protected]
  | npm info lifecycle [email protected]~predev: [email protected]
  | npm info lifecycle [email protected]~dev: [email protected]
  | > [email protected] dev /opt/app-root/src
  | > webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
  | ERROR  Failed to compile with 2 errors14:57:34
  | This dependency was not found:
  | * /opt/app-root/src/node_modules/webpack-dev-server/client/index.js?http://localhost:8080  in multi (webpack)-dev-server/client?http://localhost:8080  webpack/hot/dev-server ./src/main.js
  | To install it, you can run: npm install --save /opt/app-root/src/node_modules/webpack-dev-server/client/index.js?http://localhost:8080
  | This relative module was not found:
  | * ./src/main.js in multi (webpack)-dev-server/client?http://localhost:8080  webpack/hot/dev-server ./src/main.js

Assumed Root Cause: Missing Resolution for /opt/app-root/src/src/main.js

Initial research:

oc get pod
oc rsh <pod name>
sh-4.2$echo $PATH
/opt/rh/rh-nodejs8/root/usr/bin:/opt/app-root/src/node_modules/.bin/:/opt/app-root/src/.npm-global/bin/:/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Solution Approaches

Nr. 1: Extend $PATH to /opt/app-root/src/src/

TBC...

OpenShift templates not working on SDK/minishift

Hi all,

tried to get the dapp running on OpenShift as per the README. (See the minimal typos found here and here - fixed this before trying..).

Environment

minishift v1.20.0+1bd6d5c
CDK v3.5.0-1
oc v3.10.14
kubernetes v1.10.0+b81c8f8
macOS 10.13.6 (17G65)

oc status --suggest gives:

In project demo on server https://192.168.65.7:8443

http://blockchain-app-backend-demo.192.168.65.7.nip.io (svc/blockchain-app-backend)
  dc/blockchain-app-backend deploys istag/blockchain-app-backend:latest <-
    bc/blockchain-app-backend source builds https://github.com/itp-world/blockchain-otc-dapp.git on openshift/nodejs:8
      build #1 failed 15 minutes ago - f5d36dc: updated templates (Siamak Sadeghianfar <[email protected]>)
    deployment #1 waiting on image or update

http://blockchain-app-client-demo.192.168.65.7.nip.io (svc/blockchain-app-client)
  dc/blockchain-app-client deploys istag/blockchain-app-client:latest <-
    bc/blockchain-app-client source builds https://github.com/itp-world/blockchain-otc-dapp.git on openshift/nodejs:8
    deployment #1 failed 13 minutes ago: config change

svc/blockchain-app-mongodb - 172.30.216.109:27017
  dc/blockchain-app-mongodb deploys openshift/mongodb:3.4
    deployment #1 deployed 19 minutes ago - 1 pod

svc/parity - 172.30.130.133 ports 8180, 8545, 8546
  dc/parity deploys istag/parity:v2.0.1
    deployment #1 deployed 16 minutes ago - 0/1 pods (warning: 8 restarts)

Errors:
  * build/blockchain-app-backend-1 has failed.
    try: Inspect the build failure with 'oc logs -f bc/blockchain-app-backend'

Warnings:
  * pod/parity-1-tp674 has restarted within the last 10 minutes
  * The image trigger for dc/blockchain-app-backend will have no effect until istag/blockchain-app-backend:latest is imported or created by a build.
  * dc/parity references a volume which may only be used in a single pod at a time - this may lead to hung deployments

Info:
  * pod/blockchain-app-client-1-deploy has no liveness probe to verify pods are still running.
    try: oc set probe pod/blockchain-app-client-1-deploy --liveness ...
  * dc/parity has no readiness probe to verify pods are ready to accept traffic or ensure deployment is successful.
    try: oc set probe dc/parity --readiness ...
  * dc/parity has no liveness probe to verify pods are still running.
    try: oc set probe dc/parity --liveness ...

And oc logs -f bc/blockchain-app-backend:

Cloning "https://github.com/itp-world/blockchain-otc-dapp.git" ...
	Commit:	f5d36dcf2f7e5ccfafefba978c30b19222bf3906 (updated templates)
	Author:	Siamak Sadeghianfar <[email protected]>
	Date:	Wed Aug 8 14:01:26 2018 +0200
---> Installing application source ...
---> Installing all dependencies
npm WARN notice [SECURITY] atob has the following vulnerability: 1 moderate. Go here for more details: https://nodesecurity.io/advisories?search=atob&version=2.0.3 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] base64url has the following vulnerability: 1 moderate. Go here for more details: https://nodesecurity.io/advisories?search=base64url&version=2.0.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=4.17.4 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] stringstream has the following vulnerability: 1 moderate. Go here for more details: https://nodesecurity.io/advisories?search=stringstream&version=0.0.5 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] minimatch has the following vulnerability: 1 high. Go here for more details: https://nodesecurity.io/advisories?search=minimatch&version=0.2.14 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=1.0.2 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] minimatch has the following vulnerability: 1 high. Go here for more details: https://nodesecurity.io/advisories?search=minimatch&version=2.0.10 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] deep-extend has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=deep-extend&version=0.4.2 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
> [email protected] preinstall /opt/app-root/src/node_modules/scrypt
> node node-scrypt-preinstall.js
> [email protected] install /opt/app-root/src/node_modules/keccak
> npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."
> [email protected] rebuild /opt/app-root/src/node_modules/keccak
> node-gyp rebuild
make: Entering directory `/opt/app-root/src/node_modules/keccak/build'
CXX(target) Release/obj.target/keccak/src/addon.o
CC(target) Release/obj.target/keccak/src/libkeccak/KeccakSponge.o
CC(target) Release/obj.target/keccak/src/libkeccak/KeccakP-1600-reference.o
SOLINK_MODULE(target) Release/obj.target/keccak.node
COPY Release/keccak.node
make: Leaving directory `/opt/app-root/src/node_modules/keccak/build'
> [email protected] install /opt/app-root/src/node_modules/scrypt
> node-gyp rebuild
make: Entering directory `/opt/app-root/src/node_modules/scrypt/build'
SOLINK_MODULE(target) Release/obj.target/copied_files.node
COPY Release/copied_files.node
CC(target) Release/obj.target/scrypt_wrapper/src/util/memlimit.o
CC(target) Release/obj.target/scrypt_wrapper/src/scryptwrapper/keyderivation.o
CC(target) Release/obj.target/scrypt_wrapper/src/scryptwrapper/pickparams.o
CC(target) Release/obj.target/scrypt_wrapper/src/scryptwrapper/hash.o
AR(target) Release/obj.target/scrypt_wrapper.a
COPY Release/scrypt_wrapper.a
CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/lib/crypto/crypto_scrypt.o
CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/lib/crypto/crypto_scrypt_smix.o
CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/libcperciva/util/warnp.o
CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/libcperciva/alg/sha256.o
CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/libcperciva/util/insecure_memzero.o
CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/lib/scryptenc/scryptenc_cpuperf.o
AR(target) Release/obj.target/scrypt_lib.a
COPY Release/scrypt_lib.a
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_common.o
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_params_async.o
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_params_sync.o
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_kdf_async.o
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_kdf_sync.o
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_kdf-verify_sync.o
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_kdf-verify_async.o
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_hash_sync.o
CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_hash_async.o
CXX(target) Release/obj.target/scrypt/scrypt_node.o
SOLINK_MODULE(target) Release/obj.target/scrypt.node
COPY Release/scrypt.node
make: Leaving directory `/opt/app-root/src/node_modules/scrypt/build'
> [email protected] install /opt/app-root/src/node_modules/secp256k1
> npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."
> [email protected] rebuild /opt/app-root/src/node_modules/secp256k1
> node-gyp rebuild
make: Entering directory `/opt/app-root/src/node_modules/secp256k1/build'
CXX(target) Release/obj.target/secp256k1/src/addon.o
CXX(target) Release/obj.target/secp256k1/src/privatekey.o
../src/privatekey.cc: In function 'Nan::NAN_METHOD_RETURN_TYPE privateKeyNegate(Nan::NAN_METHOD_ARGS_TYPE)':
../src/privatekey.cc:73:61: warning: ignoring return value of 'int secp256k1_ec_privkey_negate(const secp256k1_context*, unsigned char*)', declared with attribute warn_unused_result [-Wunused-result]
   secp256k1_ec_privkey_negate(secp256k1ctx, &private_key[0]);
                                                             ^
CXX(target) Release/obj.target/secp256k1/src/publickey.o
CXX(target) Release/obj.target/secp256k1/src/signature.o
CXX(target) Release/obj.target/secp256k1/src/ecdsa.o
CXX(target) Release/obj.target/secp256k1/src/ecdh.o
CC(target) Release/obj.target/secp256k1/src/secp256k1-src/src/secp256k1.o
CC(target) Release/obj.target/secp256k1/src/secp256k1-src/contrib/lax_der_parsing.o
CC(target) Release/obj.target/secp256k1/src/secp256k1-src/contrib/lax_der_privatekey_parsing.o
SOLINK_MODULE(target) Release/obj.target/secp256k1.node
COPY Release/secp256k1.node
make: Leaving directory `/opt/app-root/src/node_modules/secp256k1/build'
> [email protected] install /opt/app-root/src/node_modules/sha3
> node-gyp rebuild
make: Entering directory `/opt/app-root/src/node_modules/sha3/build'
CXX(target) Release/obj.target/sha3/src/addon.o
../src/addon.cpp: In static member function 'static Nan::NAN_METHOD_RETURN_TYPE SHA3Hash::New(Nan::NAN_METHOD_ARGS_TYPE)':
../src/addon.cpp:59:58: warning: 'v8::Local<v8::Object> v8::Function::NewInstance(int, v8::Local<v8::Value>*) const' is deprecated (declared at /opt/app-root/src/.node-gyp/8.9.4/include/node/v8.h:3831): Use maybe version [-Wdeprecated-declarations]
    info.GetReturnValue().Set(cons->NewInstance(argc, argv));
                                                          ^
CXX(target) Release/obj.target/sha3/src/displayIntermediateValues.o
CXX(target) Release/obj.target/sha3/src/KeccakF-1600-reference.o
CXX(target) Release/obj.target/sha3/src/KeccakNISTInterface.o
CXX(target) Release/obj.target/sha3/src/KeccakSponge.o
SOLINK_MODULE(target) Release/obj.target/sha3.node
COPY Release/sha3.node
make: Leaving directory `/opt/app-root/src/node_modules/sha3/build'
> [email protected] install /opt/app-root/src/node_modules/websocket
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/opt/app-root/src/node_modules/websocket/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/obj.target/bufferutil.node
COPY Release/bufferutil.node
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/obj.target/validation.node
COPY Release/validation.node
make: Leaving directory `/opt/app-root/src/node_modules/websocket/build'
> [email protected] install /opt/app-root/src/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v2.0.0/bcrypt_lib-v2.0.0-node-v57-linux-x64-glibc.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory `/opt/app-root/src/node_modules/bcrypt/build'
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
COPY Release/bcrypt_lib.node
COPY /opt/app-root/src/node_modules/bcrypt/lib/binding/bcrypt_lib.node
TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory `/opt/app-root/src/node_modules/bcrypt/build'
added 873 packages in 104.552s
---> Building in production mode
---> Pruning the development dependencies
removed 405 packages in 15.354s
/opt/app-root/src/.npm is not a mountpoint
---> Cleaning the npm cache /opt/app-root/src/.npm
/tmp is not a mountpoint
---> Cleaning the /tmp/npm-*
Running post commit hook ...
sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
> [email protected] test /opt/app-root/src
> echo "Error: no test specified" && exit 1
Error: no test specified
npm ERR! Test failed.  See above for more details.
error: build error: container "openshift_s2i-build_blockchain-app-backend-1_demo_post-commit_25cd95d5" returned non-zero exit code: 1

And finally oc logs parity-1-tp674 -c parity:

Loading config file from /opt/parity/conf/config.toml
2018-09-05 08:23:17 UTC Starting Parity-Ethereum/v2.0.1-beta-e7dc0be-20180726/x86_64-linux-gnu/rustc1.27.2
2018-09-05 08:23:17 UTC Keys path /opt/parity/data/parity0/keys/BlockchainDemo
2018-09-05 08:23:17 UTC DB path /opt/parity/data/parity0/chains/BlockchainDemo/db/534efbc542be4adc
2018-09-05 08:23:17 UTC State DB configuration: fast
2018-09-05 08:23:17 UTC Operating mode: active
Consensus signer account not found for the current chain. You can create an account via RPC, UI or `parity account new --chain /opt/parity/conf/chain.json --keys-path /opt/parity/data/parity0/keys`.

Different problems than @drmartinberger reported, but it's anyway not working locally for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.