Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Barge issues: pdr-trueval, connecting subgraph #194

Closed
trentmc opened this issue Oct 4, 2023 · 26 comments · Fixed by #203
Closed

Barge issues: pdr-trueval, connecting subgraph #194

trentmc opened this issue Oct 4, 2023 · 26 comments · Fixed by #203
Labels
Type: Bug Something isn't working

Comments

@trentmc
Copy link
Member

trentmc commented Oct 4, 2023

See attached log.
temp.txt

@trentmc trentmc added the Type: Bug Something isn't working label Oct 4, 2023
@trentmc
Copy link
Member Author

trentmc commented Oct 4, 2023

One more error:

ocean-ocean-contracts-1  | [Error: EBUSY: resource busy or locked, rmdir '/ocean-contracts/artifacts'] {
ocean-ocean-contracts-1  |   errno: -16,
ocean-ocean-contracts-1  |   code: 'EBUSY',
ocean-ocean-contracts-1  |   syscall: 'rmdir',
ocean-ocean-contracts-1  |   path: '/ocean-contracts/artifacts'
ocean-ocean-contracts-1  | }
ocean-ocean-contracts-1  | Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
ocean-ocean-contracts-1  |   --> contracts/utils/OceanToken.sol:33:5:
ocean-ocean-contracts-1  |    |
ocean-ocean-contracts-1  | 33 |     constructor(
ocean-ocean-contracts-1  |    |     ^ (Relevant source part starts here and spans across multiple lines).

@alexcos20
Copy link
Member

One more error:

ocean-ocean-contracts-1  | [Error: EBUSY: resource busy or locked, rmdir '/ocean-contracts/artifacts'] {
ocean-ocean-contracts-1  |   errno: -16,
ocean-ocean-contracts-1  |   code: 'EBUSY',
ocean-ocean-contracts-1  |   syscall: 'rmdir',
ocean-ocean-contracts-1  |   path: '/ocean-contracts/artifacts'
ocean-ocean-contracts-1  | }
ocean-ocean-contracts-1  | Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
ocean-ocean-contracts-1  |   --> contracts/utils/OceanToken.sol:33:5:
ocean-ocean-contracts-1  |    |
ocean-ocean-contracts-1  | 33 |     constructor(
ocean-ocean-contracts-1  |    |     ^ (Relevant source part starts here and spans across multiple lines).

that is just a warning, you can ignore it

@trentmc
Copy link
Member Author

trentmc commented Oct 4, 2023

address.json.txt

@alexcos20
Copy link
Member

See attached log. temp.txt

Looks like pdr-backend is trying to connect to "172.15.0.15:8000". But on MacOs, container do not have ip addresses, so we need to find another way to connect to subgraph (maybe something like host.docker.internal:8000 ?). I don't use a Mac, so I cannot test it

@alexcos20
Copy link
Member

address.json.txt

all good, all contracts are deployed on "development" network

@trizin
Copy link
Contributor

trizin commented Oct 4, 2023

I don't see any log messages from the subgraph, could it be down? Could you check the subgraph logs?

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

I rebooted everything, cleaned everything, it's working now

My guess it was a subgraph issue. But now it's all good.

Thanks everyone for your help.

@trentmc trentmc closed this as completed Oct 6, 2023
@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

So I had it going, good.

Then I stopped it, and re-started it. Now it's failing again :(. Looks like a subgraph error. Here's the log from the subgraph docker process:

...
- Generate types for GraphQL schema
✔ Generate types for GraphQL schema

Types generated successfully


> ocean-subgraph@3.0.9 create:local-barge
> graph create oceanprotocol/ocean-subgraph --node http://172.15.0.15:8020

- Creating subgraph in Graph node: http://172.15.0.15:8020/
✖ HTTP error creating the subgraph: EHOSTUNREACH
/usr/src/app/node_modules/@oclif/core/lib/errors/index.js:21
    throw new exit_2.ExitError(code);
    ^

ExitError: EEXIT: 1
    at Object.exit (/usr/src/app/node_modules/@oclif/core/lib/errors/index.js:21:11)
    at CreateCommand.exit (/usr/src/app/node_modules/@oclif/core/lib/command.js:131:23)
    at /usr/src/app/node_modules/@graphprotocol/graph-cli/dist/commands/create.js:46:22
    at ClientHttp.Client._parseResponse (/usr/src/app/node_modules/jayson/lib/client/index.js:190:12)
    at /usr/src/app/node_modules/jayson/lib/client/index.js:149:10
    at ClientRequest.<anonymous> (/usr/src/app/node_modules/jayson/lib/client/http.js:100:7)
    at ClientRequest.emit (node:events:513:28)
    at Socket.socketErrorListener (node:_http_client:494:9)
    at Socket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:157:8) {
  oclif: { exit: 1 },
  code: 'EEXIT'
}

@trentmc trentmc reopened this Oct 6, 2023
@trizin
Copy link
Contributor

trizin commented Oct 6, 2023

Looks like the subgraph is unavailable, could you check if it's running and inspect the logs if it's running?

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

Yes, exactly, the subgraph is unavailable.

That error listed above was from the docker subgraph process.

Here's the "liveness" of the process:

trentmc@tlm-macbook: ~/code/barge $ docker ps -a|grep ubgr
94d6837431e7   oceanprotocol/subgraph:predictoor          "/usr/src/app/docker…"   7 hours ago   Up 7 minutes                                                                                         ocean-subgraph-1

And, from trentmc@tlm-macbook: ~ $ docker logs 94d6837431e7:

  • here's the full log: log.txt
  • the error reported in the comment above is at the bottom of the log

@trizin
Copy link
Contributor

trizin commented Oct 6, 2023

Thanks for providing the logs. Looks interesting, I haven't seen something like this before. Could be related to what @alexcos20 mentioned above #194 (comment) although it's weird that it works from time to time and then fails

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

[Berkay] Could be related to what @alexcos20 mentioned

[what @alexcos20 mentioned] But on MacOs, container do not have ip addresses, so we need to find another way to connect to subgraph (maybe something like host.docker.internal:8000 ?)

Yet this was working two weeks ago. And earlier today, if briefly.

Perhaps it's the following. There are two possible subgraph URLs:

export SUBGRAPH_URL="http://localhost:9000/subgraphs/name/oceanprotocol/ocean-subgraph"
export SUBGRAPH_URL="http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph"

IIRC one was working (top one?) and the other wasn't.

@trizin
Copy link
Contributor

trizin commented Oct 6, 2023

Yep first one should work. However this error occurs in the subgraph container while deploying the subgraph. Perhaps try a clean start by running the cleanup script and removing ~/.ocean folder?

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

Perhaps try a clean start by running the cleanup script and removing ~/.ocean folder?

Yep, WIP.

I hit another snag: earlier today "to be prudent" I upgraded my Docker from 4.22 to 4.24. Then Docker kept randomly hanging. After googling around, it seems many people had that issue, and the fix was to go back to 4.22.

I'll keep you posted.

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

Docker seems to be behaving better now.

However, the oceanprotocol/subgraph:predictoor container has this as its full log. Something's up I think?

trentmc@tlm-macbook: ~ $ docker logs -f 204871861e18
deploy subgraph is true
Waiting for contracts to be deployed

> ocean-subgraph@3.0.9 quickstart:barge
> node ./scripts/generatenetworkssubgraphs.js development && npm run codegen && npm run create:local-barge && npm run deploy:local-barge

Using custom ADDRESS_FILE instead of ocean-contracts npm dep
Skipping mumbai
Skipping polygon
...
Skipping sepolia
Skipping oasis_saphire

> ocean-subgraph@3.0.9 codegen
> graph codegen --output-dir src/@types

    Error: ENOENT: no such file or directory, open 'subgraph.yaml'
    Code: ENOENT

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

Good news! I think in the previous run, while I'd run the cleanup script, I had missed deleting ~/.ocean. Because in my next run, I did do that and I think it's working.

Some logging from subgraph container is below. Fingers crossed...

...
Skipping oasis_saphire
Creating subgraph.yaml for development
	 Adding veOCEAN

> ocean-subgraph@3.0.9 codegen
> graph codegen --output-dir src/@types

- Apply migrations
...
- Generate types for GraphQL schema
✔ Generate types for GraphQL schema

Types generated successfully


> ocean-subgraph@3.0.9 create:local-barge
> graph create oceanprotocol/ocean-subgraph --node http://172.15.0.15:8020

- Creating subgraph in Graph node: http://172.15.0.15:8020/
Created subgraph: oceanprotocol/ocean-subgraph

> ocean-subgraph@3.0.9 deploy:local-barge
> graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --ipfs http://172.15.0.16:5001 --node http://172.15.0.15:8020
...
  Compile data source: veFeeDistributor => build/veFeeDistributor/veFeeDistributor.wasm
- Compile subgraph
...
- Upload subgraph to IPFS
                .. QmVHM3xfMTNQUrC3psri54SeFMpQZSEWMH1X7tdM6CtMXX
- Upload subgraph to IPFS
✔ Upload subgraph to IPFS

Build completed: QmQfEowKwF6kJUXRGrjx8usvrpV8hw3nyW57QTAv5HHxF4

- Deploying to Graph node http://172.15.0.15:8020/
Deployed to http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql

Subgraph endpoints:
Queries (HTTP):     http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph

Summary of lessons so far:

  • In MacOS, use Docker 4.22 not 4.24 which freezes.
  • Before running barge, do all three cleanups, as follows. (I've already updated barge.md accordingly)
    rm -rf ~/.ocean
    ./cleanup.sh
    docker system prune -a --volumes
    

@trizin
Copy link
Contributor

trizin commented Oct 6, 2023

Great!

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

Alas, I am still having trouble getting predictoor to see the subgraph.

In console, I do the following:

cd code/pdr-backend/

# Setup virtualenv
cd pdr-backend
source venv/bin/activate

# Set envvars
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
export RPC_URL=http://127.0.0.1:8545
export SUBGRAPH_URL="http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph"
export PRIVATE_KEY="0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58"

# run random predictoor bot (agent)
python pdr_backend/predictoor/main.py 1

And the result I get from the last line is:

HTTPConnectionPool(host='172.15.0.15', port=8000): Max retries exceeded with url: /subgraphs/name/oceanprotocol/ocean-subgraph (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x1081a6690>, 'Connection to 172.15.0.15 timed out. (connect timeout=1.5)'))
No feeds found. Exiting

Also, the subgraph url of interest does not load in my browser. http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph

Help? @trizin

@trizin
Copy link
Contributor

trizin commented Oct 6, 2023

Try to use the localhost:9000 for subgraph url

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

Try to use the localhost:9000 for subgraph url

Aha! And that works! My predictoor log:

(venv) trentmc@tlm-macbook: export SUBGRAPH_URL="http://localhost:9000/subgraphs/name/oceanprotocol/ocean-subgraph"

(venv) trentmc@tlm-macbook: ~/code/pdr-backend $ python pdr_backend/predictoor/main.py 1

--------------------------------------------------------------------------------
Config:
PredictoorConfig1={private_key=0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58, rpc_url=http://127.0.0.1:8545, s_until_epoch_end=60, stake_amount=1, subgraph_url=http://localhost:9000/subgraphs/name/oceanprotocol/ocean-subgraph, _abc_impl=<_abc._abc_data object at 0x104c9ba40>, owner_addresses=[], pair_filters=[], source_filter=[], timeframe_filter=[], web3_config=<pdr_backend.util.web3_config.Web3Config object at 0x101bf3f50> /PredictoorConfig1}

................................................................................
Feeds (detailed):
...

Starting main loop...

--------------------------------------------------------------------------------
Take_step() begin.
  block_number=793, prev=0
  Got new block. Timestamp={block['timestamp']}
    Process [Feed 0x0356a ETH/USDT|binance|5m] at epoch=5655343
      282 s left in epoch (predict if <= 60 s left)
      Done feed: too early to predict
    Process [Feed 0x4bde0 BTC/TUSD|binance|5m] at epoch=5655343
...

And that url (http://localhost:9000/subgraphs/name/oceanprotocol/ocean-subgraph) also works in my browser, bringing up the expected text boxes for entering queries.

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

This issue is solved, hooray:)

@trentmc trentmc closed this as completed Oct 6, 2023
@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

@trizin so that I can update my own mental model:

  • The subgraph container reports a subgraph url of http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph

  • Yet predictoor agent & browser fail on that url

  • The agent & browser do work for this url: http://localhost:9000/subgraphs/name/oceanprotocol/ocean-subgraph

What's the relation between these urls? Why is it a remote IP address for the docker container, and a local (IP address?) for the agent & browser? Thanks!

@alexcos20
Copy link
Member

because docker on macOS does not support brige, which is the driver that we are using to create and assign ip addrs to all containers (https://docker-docs.uclv.cu/docker-for-mac/networking/#there-is-no-docker0-bridge-on-macos)

@alexcos20
Copy link
Member

and https://docker-docs.uclv.cu/docker-for-mac/networking/#per-container-ip-addressing-is-not-possible

@trentmc
Copy link
Member Author

trentmc commented Oct 6, 2023

Thanks Alex!

@trizin
Copy link
Contributor

trizin commented Oct 6, 2023

According to my knowledge:

https://github.com/oceanprotocol/barge/blob/main/compose-files/thegraph.yml#L6 This exposes the port 8000 in the container to the host network, thus it's accessible.

"172.15.0.15" is the internal ip of the container, other containers in the network can access it. As far as I know the docker network is isolated from host network unless you expose a port so you cannot access it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants