dap-ps / discover-v2

Discover all your favourite Distributed Applications, ranked in a provably fair and transparent way
Mozilla Public License 2.0
3 stars 0 forks source link

feat: testnet build #12

Closed richard-ramos closed 3 years ago

richard-ramos commented 3 years ago
jakubgs commented 3 years ago

I tried building it using yarn run create:fullbuild:testnet inside of a node:12.20.0-buster Docker container but it gets stuck on:

 | deploying contracts
 | MiniMeToken already deployed at 0xc55cf4b03948d7ebc8b9e8bad92643703811d162
 | Discover already deployed at 0x9fb115BC152aE21ECDc81c73843673fa38e4D2dB
 | (node:13838) UnhandledPromiseRejectionWarning: Error: Invalid JSON RPC response: ""
 |     at Object.InvalidResponse (/repo/node_modules/embark/node_modules/web3-Contracts/core-helpers/src/errors.js:42:16)
 |     at XMLHttpRequest.request.onreadystatechange (/repo/node_modules/embark/node_modules/web3-Contracts/providers-http/src/index.js:106:32)
 |     at XMLHttpRequestEventTarget.dispatchEvent (/repo/node_modules/embark/node_modules/xhr2-Contracts/cookies/xml-http-request-event-target.ts:44:13)
 |     at XMLHttpRequest._setReadyState (/repo/node_modules/embark/node_modules/xhr2-Contracts/cookies/xml-http-request.ts:219:8)
 |     at XMLHttpRequest._onHttpRequestError (/repo/node_modules/embark/node_modules/xhr2-Contracts/cookies/xml-http-request.ts:379:8)
 |     at ClientRequest.<anonymous> (/repo/node_modules/embark/node_modules/xhr2-Contracts/cookies/xml-http-request.ts:266:37)
 |     at ClientRequest.emit (events.js:314:20)
 |     at Socket.socketOnEnd (_http_client.js:458:9)
 |     at Socket.emit (events.js:326:22)
 |     at endReadableNT (_stream_readable.js:1241:12)
 |     at processTicksAndRejections (Contracts/internal/process/task_queues.js:84:21)
 | (node:13838) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see Contracts/https:/nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
 | (node:13838) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Restarting it seems to make it complete that step:

 | deploying contracts
 | MiniMeToken already deployed at 0xc55cf4b03948d7ebc8b9e8bad92643703811d162
 | Discover already deployed at 0x9fb115BC152aE21ECDc81c73843673fa38e4D2dB
 | finished deploying contracts
 | Finished deploying

I recall this being an issue before. No clue what can be done.

jakubgs commented 3 years ago

The deployment worked: https://raw.dev.dap.ps/

But it seems to fail to load: image

jakubgs commented 3 years ago

The BLOCKCHAIN_CONNECTION_POINT variable is definitely set in AWS Elastic Beanstalk: image

richard-ramos commented 3 years ago

For some reason it's not loading the environment variable INFURA_KEY in here

https://github.com/dap-ps/discover-v2/blob/main/WebApp/app/domain/App/blockchainUtils.ts#L75-L83

jakubgs commented 3 years ago

Wait, but that's not the backend... normally those configs are loaded in Backend/config/index.js.

Isn't WebApp just JS that gets loaded into the browser? Of course the browser wouldn't have those env variables.

richard-ramos commented 3 years ago

Good catch!! I think that's why there's an .env file, would you mind creating it in the WebApp folder, with the following lines:

INFURA_KEY=8675214b97b44e96b70d05326c61fd6a
API_HOST=localhost:4000
API_SCHEMA=http
jakubgs commented 3 years ago

Deployed the recent changes but now I'm seeing the /metadata/all endpoint timing out:

 > curl --max-time 5 https://raw.dev.dap.ps/metadata/all 
curl: (28) Operation timed out after 5000 milliseconds with 0 bytes received

I can try SSHing onto the ElasticBeanstalk host and check logs.

jakubgs commented 3 years ago

I found something:

Server started on port: 8081
(node:14661) 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.
(node:14661) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [node-01.us-east-1a.db.dev.hosts.dap.ps:27017] on first connect [MongoNetworkError: connection timed out
    at connectionFailureError (/var/app/current/node_modules/mongodb/lib/core/connection/connect.js:362:14)
    at Socket.<anonymous> (/var/app/current/node_modules/mongodb/lib/core/connection/connect.js:286:16)
    at Object.onceWrapper (events.js:420:28)
    at Socket.emit (events.js:314:20)
    at Socket.EventEmitter.emit (domain.js:483:12)
    at Socket._onTimeout (net.js:483:8)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7) {
  errorLabels: [Array],
  [Symbol(mongoErrorContextSymbol)]: {}
}]

Looks like DB access issues.

jakubgs commented 3 years ago

Looks like port is filtered for some unknown reason:

 > sudo nmap -Pn -p27017 node-01.us-east-1a.db.dev    
Starting Nmap 7.80 ( https://nmap.org ) at 2021-02-02 15:42 CET
Nmap scan report for node-01.us-east-1a.db.dev (54.90.176.24)
Host is up.
rDNS record for 54.90.176.24: ec2-54-90-176-24.compute-1.amazonaws.com

PORT      STATE    SERVICE
27017/tcp filtered mongod
jakubgs commented 3 years ago

I re-ran the ansible role and it works now:

ansible-playbook ansible/dev.yml -t mongodb-firewall
 > sudo nmap -Pn -p27017 node-01.us-east-1a.db.dev 
Starting Nmap 7.80 ( https://nmap.org ) at 2021-02-02 15:49 CET
Nmap scan report for node-01.us-east-1a.db.dev (54.90.176.24)
Host is up (0.12s latency).
rDNS record for 54.90.176.24: ec2-54-90-176-24.compute-1.amazonaws.com

PORT      STATE SERVICE
27017/tcp open  mongod

Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds
jakubgs commented 3 years ago

I tried re-creating the EB env but now it fails to start: image

jakubgs commented 3 years ago

But when I SSH onto the EC2 instance used by EB I see the API working fine:

[ec2-user@ip-10-0-120-26 ~]$ curl -s localhost:8081/healthcheck
OK

[ec2-user@ip-10-0-120-26 ~]$ curl -s localhost:8081/metadata/all
{}
jakubgs commented 3 years ago

Looks like the issue is with the ELB thinking the service is down: image

jakubgs commented 3 years ago

Okay, while re-creating the dev env I found and fixed a few issues:

And now it's up: https://raw.dev.dap.ps/

jakubgs commented 3 years ago

API works:

 > curl --max-time 5 https://raw.dev.dap.ps/metadata/all
{}

Next thing is to create the first Dapp, but I need Ropsten SNT for that.

jakubgs commented 3 years ago

IT WERKS:tm:

image