Open Marudny opened 2 years ago
It's possible to create nodejs virtual env similar to python one.
mkdir -p ~/venvs; cd ~/venvs
nodeenv --node=12.22.11 node-12.22.11
cd node-12.22.11
source bin/activate
I've created nodejs 12.22.11
env to check how compiling process looks like.
Ok, as expected it doesn't compile successfully:
compiling solidity contracts...
/home/archie/work/dap-ps/discover/.embark/contracts/token/MiniMeToken.sol:273:75: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
function approve(address _spender, uint256 _amount) external returns (bool success) {
^----------^
/home/archie/work/dap-ps/discover/.embark/contracts/token/MiniMeToken.sol:572:5: Warning: Function state mutability can be restricted to view
function isContract(address _addr) internal returns(bool) {
^ (Relevant source part starts here and spans across multiple lines).
assuming Controlled to be an interface
assuming ApproveAndCallFallBack to be an interface
assuming ERC20Token to be an interface
assuming MiniMeTokenInterface to be an interface
assuming TokenController to be an interface
assuming TokenFactory to be an interface
To get more details on interface Smart contracts, go here: https://embark.status.im/docs/troubleshooting.html#Assuming-Contract-to-be-an-interface
deploying contracts
[Discover]: Returned error: Returned error: insufficient funds for gas * price + value
[DiscoverKyberSwap]: Returned error: Returned error: insufficient funds for gas * price + value
Error deploying contracts. Please fix errors to continue.
Finished deploying
[ -d full-build ] || mkdir -p full-build
cp .npmrc full-build/
if [ -f ./full-build/yarn.lock ]; then \
cmp -s ./back-end/yarn.lock ./full-build/yarn.lock; \
RETVAL=$?; \
if [ ! $RETVAL -eq 0 ]; then \
echo "yarn.lock is different. Removing node_modules and replacingyarn.lock"; \
rm -rf full-build/yarn.lock full-build/node_modules; \
fi \
fi
rsync -r --exclude node_modules ./back-end/* ./full-build/
./node_modules/.bin/react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run the following command: `yarn upgrade`
Failed to compile.
Let see how it works on node 14
.
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (/home/archie/work/dap-ps/discover/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/home/archie/work/dap-ps/discover/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/home/archie/work/dap-ps/discover/node_modules/which/which.js:80:29)
gyp verb `which` failed at /home/archie/work/dap-ps/discover/node_modules/which/which.js:89:16
gyp verb `which` failed at /home/archie/work/dap-ps/discover/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /home/archie/work/dap-ps/discover/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:191:21)
gyp verb `which` failed python2 Error: not found: python2
gyp verb `which` failed at getNotFoundError (/home/archie/work/dap-ps/discover/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/home/archie/work/dap-ps/discover/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/home/archie/work/dap-ps/discover/node_modules/which/which.js:80:29)
gyp verb `which` failed at /home/archie/work/dap-ps/discover/node_modules/which/which.js:89:16
gyp verb `which` failed at /home/archie/work/dap-ps/discover/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /home/archie/work/dap-ps/discover/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:191:21) {
gyp verb `which` failed code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
Well, it's so old that python2
is required... let's create venv with python2 and try again.
at /home/archie/work/dap-ps/discover/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:276
at f.<anonymous> (/home/archie/work/dap-ps/discover/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:2238)
at f.emit (events.js:400:28)
at f.destroy (/home/archie/work/dap-ps/discover/node_modules/ganache-cli/build/ganache-core.node.cli.js:29:691909)
at finish (internal/streams/writable.js:670:14)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
make: *** [Makefile:53: compile-contracts] Error 1
Got progress.
https://github.com/trufflesuite/ganache/issues/568
It's a bug in a ganache-cli
, installing newer, beta version should help: npm install ganache-core@beta -E
After installing newer version it's required to install required dependencies by calling npm install
Faced the same error on Node 14
env.
/home/archie/work/dap-ps/discover/.embark/contracts/token/MiniMeToken.sol:273:75: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
function approve(address _spender, uint256 _amount) external returns (bool success) {
^----------^
/home/archie/work/dap-ps/discover/.embark/contracts/token/MiniMeToken.sol:572:5: Warning: Function state mutability can be restricted to view
function isContract(address _addr) internal returns(bool) {
^ (Relevant source part starts here and spans across multiple lines).
assuming Controlled to be an interface
assuming ApproveAndCallFallBack to be an interface
assuming ERC20Token to be an interface
assuming MiniMeTokenInterface to be an interface
assuming TokenController to be an interface
assuming TokenFactory to be an interface
To get more details on interface Smart contracts, go here: https://framework.embarklabs.io/docs/troubleshooting.html#Assuming-Contract-to-be-an-interface
deploying contracts
[Discover]: Returned error: Returned error: insufficient funds for gas * price + value
[DiscoverKyberSwap]: Returned error: Returned error: insufficient funds for gas * price + value
Error deploying contracts. Please fix errors to continue.
This is not an error we care about:
Error deploying contracts. Please fix errors to continue.
We just want to compile the solidity contract, we don't care about deploying it. We just need the ABI to be able to build the app.
You can get the logs for failed deployment from here:
Here's the failure in /var/log/nodejs/nodejs.log
:
Server started on port: 8081
(node:12898) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Warning: no saslprep library specified. Passwords will not be sanitized
(node:12898) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Warning: no saslprep library specified. Passwords will not be sanitized
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at createStrictSyntaxError (/var/app/current/node_modules/body-parser/lib/types/json.js:158:10)
at parse (/var/app/current/node_modules/body-parser/lib/types/json.js:83:15)
at /var/app/current/node_modules/body-parser/lib/read.js:121:18
at invokeCallback (/var/app/current/node_modules/raw-body/index.js:224:16)
at done (/var/app/current/node_modules/raw-body/index.js:213:7)
at IncomingMessage.onEnd (/var/app/current/node_modules/raw-body/index.js:273:7)
at IncomingMessage.emit (events.js:314:20)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
In order to get things building locally I used a Nix shell like this:
NIXPKGS_ALLOW_INSECURE=1 nix-shell
With this shell.nix
config:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
name = "discover";
buildInputs = with pkgs; [
nodejs-12_x
(yarn.override { nodejs = nodejs-12_x; })
python2
];
}
I also had to upgrade node-sass
or compilations would fail, this also involved purging yarn.lock
:
diff --git a/package.json b/package.json
index 9d49596..6ef1eb6 100644
--- a/package.json
+++ b/package.json
@@ -28,7 +28,7 @@
"history": "^4.7.2",
"idb": "4.0.3",
"moment": "^2.24.0",
- "node-sass": "^4.11.0",
+ "node-sass": "^4.14.1",
"prop-types": "^15.7.2",
"rc-slider": "8.6.9",
"rc-tooltip": "3.7.3",
Newest still supports NodeJS 12: https://github.com/sass/node-sass/releases/tag/v7.0.1
But it fails at build time:
./src/modules/Terms/Terms.module.scss
Error: Node Sass version 7.0.1 is incompatible with ^4.0.0.
Actually. After purging all of ~/.yarn
and ~/.cache/yarn
and node_modules
and build in that Nix shell from above without changing package.json
it does build successfully:
[nix-shell:~/work/dap-ps/discover]$ yarn run build:dev
yarn run v1.22.18
$ ./node_modules/.bin/cross-env NODE_ENV=development make all
rm -fr full-build
rm -f app.zip
./node_modules/.bin/embark build "testnet"
...
adding: logs.log (deflated 77%)
adding: utils/ (stored 0%)
adding: utils/authorization-utils.js (deflated 48%)
adding: .npmrc (deflated 12%)
SUCCESS! Use the app.zip file.
Done in 99.27s.
[nix-shell:~/work/dap-ps/discover]$ ls -l app.zip
-rw-r--r-- 1 jakubgs jakubgs 10732358 May 24 15:15 app.zip
But the question is, will it work.
Started a new deployment:
The API works, as far as I can tell:
> c https://raw.dev.dap.ps/metadata/all | jq -c '.[].details | { name, url, category }'
{"name":"TEH REI","url":"https://teh.rei","category":"COLLECTIBLES"}
{"name":"Matcha","url":"https://matcha.xyz","category":"EXCHANGES"}
{"name":"Gitcoin Grants","url":"https://gitcoin.co/grants","category":"UTILITIES"}
{"name":"1inch Exchange","url":"https://1inch.exchange","category":"EXCHANGES"}
{"name":"1 Inch Exchange","url":"https://1inch.exchange","category":"EXCHANGES"}
Which matches the MongoDB contents:
> db.dappsmetadatas.find({}, {"details.name": 1, "details.url": 1})
{ "_id" : ObjectId("6019bed289c3d16e9199b985"), "details" : { "name" : "TEH REI", "url" : "https://teh.rei" } }
{ "_id" : ObjectId("6045e98b8071110d03266a44"), "details" : { "name" : "Matcha", "url" : "https://matcha.xyz" } }
{ "_id" : ObjectId("6045ea068071110d03266a46"), "details" : { "name" : "Gitcoin Grants", "url" : "https://gitcoin.co/grants" } }
{ "_id" : ObjectId("6045ea4d8071110d03266a48"), "details" : { "name" : "1inch Exchange", "url" : "https://1inch.exchange" } }
{ "_id" : ObjectId("6045eaac8071110d03266a4a"), "details" : { "name" : "1 Inch Exchange", "url" : "https://1inch.exchange" } }
So that's nice.
And yet it fails to deploy:
I started a rebuild for shits and giggles:
So don't be surprised.
I logged into the current dev
EB host and found that the DeprecationWarning
line are there, but that's it:
[ec2-user@ip-10-0-98-142 ~]$ cat /var/log/nodejs/nodejs.log
Server started on port: 8081
(node:9725) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Warning: no saslprep library specified. Passwords will not be sanitized
(node:9725) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Warning: no saslprep library specified. Passwords will not be sanitized
I'm wondering if your nix
env is really that pure. As I'm not using nix
I tried to use docker
to build the app with the following Dockerfile
:
FROM node:12.22.12-buster
ADD . /work
WORKDIR /work
RUN apt-get update && apt-get install -y make zip rsync
RUN yarn install
RUN yarn run build:prod
And can build prod app without issues:
[+] Building 138.3s (11/11) FINISHED
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 198B
=> [internal] load .dockerignore
=> => transferring context: 2B
=> [internal] load metadata for docker.io/library/node:12.22.12-buster
=> [internal] load build context
=> => transferring context: 30.30kB
=> CACHED [1/6] FROM docker.io/library/node:12.22.12-buster
=> [2/6] ADD . /work
=> [3/6] WORKDIR /work
=> [4/6] RUN apt-get update && apt-get install -y make zip rsync
=> [5/6] RUN yarn install
=> [6/6] RUN yarn run build:prod
=> exporting to image
=> => exporting layers
=> => writing image sha256:5db744af36e47e926c04bee99f26333a6ec3ff55aaac363387108a28de337dea
However building the dev
version ends with the following error:
#10 0.416 yarn run v1.22.18
#10 0.437 $ ./node_modules/.bin/cross-env NODE_ENV=development make all
#10 0.473 rm -fr full-build
#10 0.474 rm -f app.zip
#10 0.475 ./node_modules/.bin/embark build "testnet"
#10 0.948 ===== locale PO detected but not supported, default: en =====
#10 0.951
#10 0.951 === Cannot unlock account - account config missing ===
#10 0.951 Geth is configured to sync to a testnet/livenet and needs to unlock an account to allow your dApp to interact with geth, however, the address and password must be specified in your blockchain config. Please update your blockchain config with a valid address and password:
#10 0.951 - config/blockchain.js > testnet > account
#10 0.951
#10 0.951 Please also make sure the keystore file for the account is located at:
#10 0.951 - Mac: ~/Library/Ethereum/testnet/keystore
#10 0.951 - Linux: ~/.ethereum/testnet/keystore
#10 0.951 - Windows: %APPDATA%\Ethereum\testnet\keystore
#10 0.951
#10 0.951 Alternatively, you could change config/blockchain.js > testnet > networkType to "custom"
#10 0.951
#10 2.556 loaded plugins: embark-solium, embark-etherscan-verifier, @trailofbits/embark-contract-info
#10 3.484 loading solc compiler...
#10 3.509 HTTP Proxy for node endpoint https://ropsten.infura.io/v3/8675214b97b44e96b70d05326c61fd6a listening on http://localhost:8555
#10 3.881 - Downloading and installing solc 0.5.2...
#10 3.881
#10 9.470 ✔ Finished downloading and installing solc 0.5.2 in 5.6s
#10 9.470
#10 9.715 compiling solidity contracts...
#10 14.69 /work/.embark/contracts/token/MiniMeToken.sol:273:75: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
#10 14.69 function approve(address _spender, uint256 _amount) external returns (bool success) {
#10 14.69 ^----------^
#10 14.69
#10 14.69 /work/.embark/contracts/token/MiniMeToken.sol:572:5: Warning: Function state mutability can be restricted to view
#10 14.69 function isContract(address _addr) internal returns(bool) {
#10 14.69 ^ (Relevant source part starts here and spans across multiple lines).
#10 14.69
#10 14.71 assuming Controlled to be an interface
#10 14.71 assuming ApproveAndCallFallBack to be an interface
#10 14.71 assuming ERC20Token to be an interface
#10 14.71 assuming MiniMeTokenInterface to be an interface
#10 14.71 assuming TokenController to be an interface
#10 14.71 assuming TokenFactory to be an interface
#10 14.71 To get more details on interface Smart contracts, go here: https://embark.status.im/docs/troubleshooting.html#Assuming-Contract-to-be-an-interface
#10 14.71 deploying contracts
#10 16.25 Error deploying contract Discover
#10 16.25 [Discover]: Returned error: Returned error: gas required exceeds allowance (52300)
#10 17.04 Error deploying contract DiscoverKyberSwap
#10 17.04 [DiscoverKyberSwap]: Returned error: Returned error: gas required exceeds allowance (52300)
#10 17.04 Error deploying contracts. Please fix errors to continue.
#10 17.05 Finished deploying
#10 17.07 [ -d full-build ] || mkdir -p full-build
#10 17.07 cp .npmrc full-build/
#10 17.07 cp -r back-end/* full-build/
#10 17.07 ./node_modules/.bin/react-scripts build
#10 17.75 Creating an optimized production build...
#10 18.79 Browserslist: caniuse-lite is outdated. Please run the following command: `yarn upgrade`
#10 21.81 Failed to compile.
#10 21.81
#10 21.81 ./src/common/blockchain/services/discover-service/discover-service.js
#10 21.81 Cannot find file '../../../../embarkArtifacts/contracts/Discover' in './src/common/blockchain/services/discover-service'.
#10 21.81
#10 21.81
#10 21.83 make: *** [Makefile:56: compile-js] Error 1
#10 21.85 error Command failed with exit code 2.
#10 21.85 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I'm wondering if your
nix
env is really that pure.
It's not if you don't use the --pure
flag: https://nixos.org/manual/nix/stable/command-ref/nix-shell.html#options
Also, only nix-build
runs in a sandbox, nix-shell
just creates a shell that still exists within the context of your environment.
I've managed to build the app using this branch:
It appears to work without errors:
[ec2-user@ip-10-0-98-142 ~]$ cat /var/log/nodejs/nodejs.log
Server started on port: 8081
(node:9725) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Warning: no saslprep library specified. Passwords will not be sanitized
(node:9725) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Warning: no saslprep library specified. Passwords will not be sanitized
Server started on port: 8081
...
The secret sauce was running yarn install
in back-end
folder(stupid name).
And still it fails. Maybe it would be better just to try to make a new env with AL2:
I tested it locally with yarn server-start
and it runs fine:
[nix-shell:~/work/dap-ps/discover]$ export DB_CONNECTION="mongodb://${USER}:${PASS}@${HOST}:27017/${DB}"
[nix-shell:~/work/dap-ps/discover]$ yarn server-start
yarn run v1.22.18
$ node ./full-build/server.js
Server started on port: 4000
(node:407316) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Warning: no saslprep library specified. Passwords will not be sanitized
(node:407316) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Warning: no saslprep library specified. Passwords will not be sanitized
Yeah, I'm suspecting nginx, which is by default it trying to send traffic to the backend port 5000. https://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/nodejs-platform-proxy.html
There is no PORT
variable defined in our env. I will work on that.
Maybe I'm wrong, but as I understand the flow is: AWS LB -> NGINX Proxy -> NodeJS App
. On the flip side health check in dev env
is defined as tcp port 80
check... I will work on that.
On Amazon Linux AMI Node.js platform versions (preceding Amazon Linux 2), Elastic Beanstalk configures the proxy to forward requests to your application on port 8081.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-platform-proxy.html
Also: https://github.com/dap-ps/infra-dapps/blob/d545adceaad51eebca724e17e11b7d878e134067/dev.tf#L5
You can try changing the ssh key for EB env so you can access the EB hosts once they get re-created.
npm ERR! code EEXIST
npm ERR! path /tmp/deployment/application/node_modules/.bin/nodemon
npm ERR! Refusing to delete /tmp/deployment/application/node_modules/.bin/nodemon: is outside /tmp/deployment/application/node_modules/nodemon and not a link
npm ERR! File exists: /tmp/deployment/application/node_modules/.bin/nodemon
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/.npm/_logs/2022-05-27T10_23_50_551Z-debug.log
Running npm install: /opt/elasticbeanstalk/node-install/node-v12.22.12-linux-x64/bin/npm
Setting npm config jobs to 1
npm config jobs set to 1
Running npm with --production flag
Failed to run npm install. Snapshot logs for more details.
UTC 2022/05/27 10:23:50 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log
Traceback (most recent call last):
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
main()
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
node_version_manager.run_npm_install(options.app_path)
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
raise e
subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v12.22.12-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)
[2022-05-27T10:23:50.594Z] INFO [11413] - [Application update app-20210308-11@91/AppDeployStage0/AppDeployPreHook/50npm.sh] : Activity failed.
[2022-05-27T10:23:50.595Z] INFO [11413] - [Application update app-20210308-11@91/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2022-05-27T10:23:50.595Z] INFO [11413] - [Application update app-20210308-11@91/AppDeployStage0] : Activity failed.
[2022-05-27T10:23:50.596Z] INFO [11413] - [Application update app-20210308-11@91] : Completed activity. Result:
Application update - Command CMD-AppDeploy failed
Called npm install --production
in local env, fixed all issues (removed .bin
directories) and now application has problems with modules - part of them is not visible.
I'm seeing the same issue using the pure Nix shell from https://github.com/dap-ps/discover/pull/113:
...
[ -d full-build ] || mkdir -p full-build
cp .npmrc full-build/
cp -r back-end/* full-build/
./node_modules/.bin/react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run the following command: `yarn upgrade`
Failed to compile.
./src/common/blockchain/services/discover-service/discover-service.js
Cannot find file '../../../../embarkArtifacts/contracts/Discover' in './src/common/blockchain/services/discover-service'.
make: *** [Makefile:57: compile-js] Error 1
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
And indeed the file is missing from src/embarkArtifacts/contracts
:
> ls -l src/embarkArtifacts/contracts
total 174
-rw-r--r-- 1 jakubgs jakubgs 1421 May 31 11:16 ApproveAndCallFallBack.js
-rw-r--r-- 1 jakubgs jakubgs 5752 May 31 11:16 BancorFormula.js
-rw-r--r-- 1 jakubgs jakubgs 1473 May 31 11:16 Controlled.js
-rw-r--r-- 1 jakubgs jakubgs 2944 May 31 11:16 ERC20Token.js
-rw-r--r-- 1 jakubgs jakubgs 727 May 31 11:16 index.js
-rw-r--r-- 1 jakubgs jakubgs 6227 May 31 11:16 KyberNetworkProxy.js
-rw-r--r-- 1 jakubgs jakubgs 51519 May 31 11:16 MiniMeTokenFactory.js
-rw-r--r-- 1 jakubgs jakubgs 5244 May 31 11:16 MiniMeTokenInterface.js
-rw-r--r-- 1 jakubgs jakubgs 52016 May 31 11:16 MiniMeToken.js
-rw-r--r-- 1 jakubgs jakubgs 1749 May 31 11:16 SafeMath.js
-rw-r--r-- 1 jakubgs jakubgs 35967 May 31 11:16 TestBancorFormula.js
-rw-r--r-- 1 jakubgs jakubgs 1869 May 31 11:16 TokenController.js
-rw-r--r-- 1 jakubgs jakubgs 1491 May 31 11:16 TokenFactory.js
Maybe someone from the old Embark team could help you figure this one out.
Thanks to the Richard, we are able to generate Discover.js
file and compile application.
Steps that Richard took:
node v10.17.0
, npm install -g embark@5.1.0
, npm install -g ganache-cli
contracts.js
in development these addresses from shared.testnet.chains.json
:
address: "0x9b4707BbAcD138c6cB048D0486D00b883cf0377D"
},
DiscoverKyberSwap: {
address: "0x7e6d281FEe920Acc28b7166f28c7cE467C2bADa2"
}
embark run
to generate the .js filesAnyway, app created by yarn
still fails.
Require stack:
- /var/app/current/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/var/app/current/server.js:2:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/app/current/server.js' ]
}
Server started on port: 8081
(node:26008) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Warning: no saslprep library specified. Passwords will not be sanitized
(node:26008) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Warning: no saslprep library specified. Passwords will not be sanitized
Server started on port: 8081```
And deployment log:
``` npm ERR! code EEXIST
npm ERR! path /tmp/deployment/application/node_modules/.bin/nodemon
npm ERR! Refusing to delete /tmp/deployment/application/node_modules/.bin/nodemon: is outside /tmp/deployment/application/node_modules/nodemon and not a link
npm ERR! File exists: /tmp/deployment/application/node_modules/.bin/nodemon
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/.npm/_logs/2022-06-07T14_35_04_937Z-debug.log
Running npm install: /opt/elasticbeanstalk/node-install/node-v12.22.12-linux-x64/bin/npm
Setting npm config jobs to 1
npm config jobs set to 1
Running npm with --production flag
Failed to run npm install. Snapshot logs for more details.
UTC 2022/06/07 14:35:04 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log
Traceback (most recent call last):
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
main()
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
node_version_manager.run_npm_install(options.app_path)
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
raise e
subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v12.22.12-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)```
Seems `yarn` and `npm` are incompatible.
That app cannot be compiled on node 12
:
npm install
throws:
/home/archie/.cache/node-gyp/12.22.12/include/node/v8.h:2686:31: note: candidate expects 1 argument, 0 provided
2686 | Local<Object> ToObject(Isolate* isolate) const);
| ^~~~~~~~
/home/archie/.cache/node-gyp/12.22.12/include/node/v8config.h:328:3: note: in definition of macro 'V8_DEPRECATED'
328 | declarator __attribute__((deprecated(message)))
| ^~~~~~~~~~
In file included from ../src/addon.cc:1:
../src/addon.cc: At global scope:
/home/archie/.cache/node-gyp/12.22.12/include/node/node.h:736:7: warning: cast between incompatible function types from 'void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE, Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Object>)'} to 'node::addon_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)'} [-Wcast-function-type]
736 | (node::addon_register_func) (regfunc), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/archie/.cache/node-gyp/12.22.12/include/node/node.h:770:3: note: in expansion of macro 'NODE_MODULE_X'
770 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
| ^~~~~~~~~~~~~
../src/addon.cc:86:1: note: in expansion of macro 'NODE_MODULE'
86 | NODE_MODULE(keccak, Init)
| ^~~~~~~~~~~
make: *** [keccak.target.mk:125: Release/obj.target/keccak/src/addon.o] Error 1
make: Leaving directory '/home/archie/work/dap-ps/discover/node_modules/ethereumjs-vm/node_modules/keccak/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/nix/store/0rg4g4xgybjlvz706wcsdngw0x8zm1fh-nodejs-12.22.12/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 5.17.0-8-generic
gyp ERR! command "/nix/store/0rg4g4xgybjlvz706wcsdngw0x8zm1fh-nodejs-12.22.12/bin/node" "/nix/store/0rg4g4xgybjlvz706wcsdngw0x8zm1fh-nodejs-12.22.12/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/archie/work/dap-ps/discover/node_modules/ethereumjs-vm/node_modules/keccak
gyp ERR! node -v v12.22.12
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keccak@1.4.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
https://github.com/nodejs/node-gyp/issues/1941
Let's try to build it on node 10
or update node-gyp
package.
Ok, I've built app using node 10
and npm
. App is currently deployed to AWS. Deployment went fine, but app is throwing:
Error: Cannot find module './config'
Require stack:
- /var/app/current/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/var/app/current/server.js:2:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/app/current/server.js' ]
}
Server started on port: 8081
It starts without issues on my desktop:
[nix-shell:~/work/dap-ps/discover/full-build]$ npm start
> status-discover-backend@1.0.0 start /home/archie/work/dap-ps/discover/full-build
> nodemon server.js
[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Server started on port: 4000
(node:312650) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:312650) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:312650) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:312650) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
(node:312650) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Warning: no saslprep library specified. Passwords will not be sanitized
(node:312650) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Warning: no saslprep library specified. Passwords will not be sanitized
Would be good to upload the missing Discover*.js
files Richard built successfully:
Added .txt
to cheat a bit and get GitHub to accept the files.
We can debug loading of Node.JS modules using these methods:
And check what paths Node.JS is checking when searching for the ./config
from:
https://github.com/dap-ps/discover/blob/97bfb18d67caa02bae00bde3afbc2c6006815ab7/back-end/server.js#L2
As you've said, the app loads via: http://dev-dap-ps-app.eba-6uufvgb2.us-east-1.elasticbeanstalk.com/ But I'm seeing this error:
error Error: Error fetching dapps. Details: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
at a.<anonymous> (discover-service.js:92:13)
at s (main.d0e1b601.chunk.js:2:204986)
at Generator._invoke (main.d0e1b601.chunk.js:2:204739)
at Generator.throw (main.d0e1b601.chunk.js:2:205349)
at n (2.0115c723.chunk.js:sourcemap:2:27538)
at s (2.0115c723.chunk.js:sourcemap:2:27777)
I have seen this before, but it was transitory:
But I verified just in case that the default Ropsten Infura endpoint works, and it does:
> echo '{"jsonrpc":"2.0","method":"eth_blockNumber","params": [],"id":1}' | websocat wss://ropsten.infura.io/ws/v3/8675214b97b44e96b70d05326c61fd6a
{"jsonrpc":"2.0","id":1,"result":"0xbcfb8b"}
> c -XPOST https://ropsten.infura.io/v3/8675214b97b44e96b70d05326c61fd6a -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params": [],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0xbcfb8c"}
The error appears to come from here:
ABICoder.prototype.decodeParameters = function (outputs, bytes) {
if (outputs.length > 0 && (!bytes || bytes === '0x' || bytes === '0X')) {
throw new Error(
'Returned values aren\'t valid, did it run Out of Gas? ' +
'You might also see this error if you are not using the ' +
'correct ABI for the contract you are retrieving data from, ' +
'requesting data from a block number that does not exist, ' +
'or querying a node which is not fully synced.'
);
}
Which appears to be triggered by this call to DiscoverContract.methods.getDAppsCount()
:
https://github.com/dap-ps/discover/blob/97bfb18d67caa02bae00bde3afbc2c6006815ab7/src/common/blockchain/services/discover-service/discover-service.js#L76-L80
My best guess is that it's some incompatibility with MetaMask, but that doesn't explain why it works on prod.
I managed to get the env upgraded by manually adjusting the ZIP we deployed previously: https://github.com/dap-ps/infra-dapps/issues/22#issuecomment-1278837731
But there are issues with the submission popup that I'm not sure how to fix. I tried building the prod app but it seems to require some ancient Geth version - 1.9.10 or earlier - and even if it has it it appears to just get stuck in some kind of race condition and the contract is never built.
As mentioned here: https://github.com/dap-ps/infra-dapps/issues/22 Elastic Beanstalk is only in V2 version. According to the https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-retiring.html#platforms-retiring.nodejs the lowest supported version of nodejs is
14.0.0
hence is required to compilediscover
innodejs 14
env.