oceanprotocol / df-py

veOCEAN & Data Farming backend
Apache License 2.0
3 stars 9 forks source link

Error: "ContractNotFound: No contract deployed at 0x17d5" #407

Closed trentmc closed 1 year ago

trentmc commented 1 year ago

The bug / how to reproduce

First, get barge going as usual for df-py, including export CONTRACTS_VERSIONS=v1.1.0 before starting it.

Then, in a separate console, try to do anything with df-py. For example:

brownie test util/test/test_calcrewards.py

Traceback: (full log)

INTERNALERROR>   File "/home/trentmc/code/df-py/util/networkutil.py", line 110, in connect
INTERNALERROR>     network.connect(chainIdToNetwork(chainID))
INTERNALERROR>   File "/home/trentmc/code/df-py/venv/lib/python3.10/site-packages/brownie/network/main.py", line 55, in connect
INTERNALERROR>     p._load_deployments()
INTERNALERROR>   File "/home/trentmc/code/df-py/venv/lib/python3.10/site-packages/brownie/project/main.py", line 384, in _load_deployments
INTERNALERROR>     contract = Contract.from_abi(  # type: ignore
INTERNALERROR>   File "/home/trentmc/code/df-py/venv/lib/python3.10/site-packages/brownie/network/contract.py", line 969, in from_abi
INTERNALERROR>     _DeployedContractBase.__init__(self, address, owner, None)
INTERNALERROR>   File "/home/trentmc/code/df-py/venv/lib/python3.10/site-packages/brownie/network/contract.py", line 708, in __init__
INTERNALERROR>     raise ContractNotFound(f"No contract deployed at {address}")
INTERNALERROR> brownie.exceptions.ContractNotFound: No contract deployed at 0x17d55A3501999FFBF9b0623cDB258611419d01F5

More debugging info

If I run the following:

docker logs ocean_ocean-contracts_1 

Then I get the following: (full log)

deploy contracts is true
Nothing to compile
 ·----------------------------|--------------|----------------·
 |  Contract Name             ·  Size (KiB)  ·  Change (KiB)  │
 ·····························|··············|·················
...
 |  BFactory                  ·       1.359  ·                │
 ·····························|··············|·················
 |  BMath                     ·       3.721  ·                │
 ·····························|··············|·················
...
Deploying OPF Community Fee
    Run the following to verify on etherscan
    npx hardhat verify --network development 0x2fC1fd21cb222Dc180Ef817dE4c426fd9230b5A5 0xe2DD09d719Da89e5a3D0F2549c7E24566e947260 0xe2DD09d719Da89e5a3D0F2549c7
...

That log does not contain 0x17d55A3501999FFBF9b0623cDB258611419d01F5.

Where does that come from? Let's dig more:

(venv) trentmc@trentmc-xps:~/code/df-py$ grep -r 0x17d55A3501999FFBF9b0623cDB258611419d01F5 | cut -c -120
build/deployments/8996/0x17d55A3501999FFBF9b0623cDB258611419d01F5.json:{"abi": [{"inputs": [{"internalType": "string", "
build/deployments/map.json:      "0x17d55A3501999FFBF9b0623cDB258611419d01F5"

Interesting! A couple files in my build/ directory have that.

Let's delete build/ directory and re-run. Result: (full log)

(venv) trentmc@trentmc-xps:~/code/df-py$ rm -rf build
(venv) trentmc@trentmc-xps:~/code/df-py$ brownie test
util/test/test_calcrewards.py::test_getNftAddrs -s
Brownie v1.19.2 - Python development framework for Ethereum
Compiling contracts...
  Vyper version: 0.3.1
Generating build data...
 - DelegationProxy
 - veDelegation
...
 - ERC20Template
...
 - veAllocate
INTERNALERROR> Traceback (most recent call last):
...
INTERNALERROR>     recordDevDeployedContracts()
INTERNALERROR>   File "/home/trentmc/code/df-py/venv/lib/python3.10/site-packages/enforce_typing/decorator.py", line 29, in wrapper
INTERNALERROR>     return func(*args, **kwargs)
INTERNALERROR>   File "/home/trentmc/code/df-py/util/oceanutil.py", line 23, in recordDevDeployedContracts
INTERNALERROR>     assert brownie.network.is_connected()
INTERNALERROR> AssertionError

Discussion

What's happening: it compiles the contracts

Why is this? It's kinda legacy, and was used for testing. We can clean it all up now, now that barge is there with all the contracts including ve. That's the cleanest path forward to fix this issue.

Or in Alex's words: "it simulates real world, where you already have the contracts on a remote network." Thanks to Alex for helping to debug this issue.

TODO for this issue

Best way: Remove brownie compiling. Remove the contracts. It should all just use barge.

BUT, we have workarounds to be able to work on other issues (e.g. #403), without needing to do this issue.

Workaround 1. Found by Trent in experiments here

Workaround 2. Found by Berkay

trentmc commented 1 year ago

We now have two workarounds to the issue; see the bottom of the description.

The original idea of how to fix was "Remove brownie compiling. Remove the contracts. It should all just use barge." I took a swing at that in this PR. However it encountered problems.

I realize now: it's not a small task to do this. And we don't need to. Better is to simply move on to "decentralize & automate df-py", where any possible work on "remove brownie compiling" would be obsoleted anyway.

Therefore, closing this issue.