ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
870 stars 133 forks source link

Aave protocol dependency not found - unknown version when tag exists #505

Closed PatrickAlphaC closed 2 years ago

PatrickAlphaC commented 2 years ago

Environment information

Full virtual environment:

aiohttp==3.8.1
aiosignal==1.2.0
appnope==0.1.2
asttokens==2.0.5
async-timeout==4.0.2
attrs==21.4.0
backcall==0.2.0
base58==2.1.1
bitarray==1.2.2
black==22.1.0
cached-property==1.5.2
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.12
click==8.0.4
colorama==0.4.4
commonmark==0.9.1
cytoolz==0.11.2
dataclassy==0.10.4
decorator==5.1.1
Deprecated==1.2.13
eth-abi==2.1.1
eth-account==0.5.7
eth-ape==0.1.0b5
eth-bloom==1.0.4
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.4
eth-rlp==0.2.1
eth-tester==0.6.0b6
eth-typing==2.3.0
eth-utils==1.10.0
ethpm-types==0.1.0b7
executing==0.8.2
frozenlist==1.3.0
hexbytes==0.2.2
idna==3.3
importlib-metadata==4.11.1
iniconfig==1.1.1
ipfshttpclient==0.8.0a2
ipython==8.0.1
jedi==0.18.1
jsonschema==3.2.0
lru-dict==1.1.7
matplotlib-inline==0.1.3
multiaddr==0.0.9
multidict==6.0.2
mypy-extensions==0.4.3
netaddr==0.8.0
packaging==20.9
parsimonious==0.8.1
parso==0.8.3
pathspec==0.9.0
pexpect==4.8.0
pickleshare==0.7.5
platformdirs==2.5.1
pluggy==0.13.1
prompt-toolkit==3.0.28
protobuf==3.19.4
ptyprocess==0.7.0
pure-eval==0.2.2
py==1.11.0
py-ecc==5.2.0
py-evm==0.5.0a3
py-geth==3.7.0
pycparser==2.21
pycryptodome==3.14.1
pydantic==1.9.0
pyethash==0.1.27
pygit2==1.9.0
PyGithub==1.55
Pygments==2.11.2
PyJWT==2.3.0
PyNaCl==1.5.0
pyparsing==3.0.7
pyrsistent==0.18.1
pysha3==1.0.2
pytest==6.2.5
python-dateutil==2.8.2
PyYAML==6.0
requests==2.27.1
rich==10.16.2
rlp==2.0.1
semantic-version==2.9.0
six==1.16.0
sortedcontainers==2.4.0
stack-data==0.2.0
toml==0.10.2
tomli==2.0.1
toolz==0.11.2
tqdm==4.62.3
traitlets==5.1.1
trie==2.0.0a5
typing-extensions==3.10.0.2
urllib3==1.26.8
varint==1.0.2
wcwidth==0.2.5
web3==5.27.0
websockets==9.1
wrapt==1.13.3
yarl==1.7.2
zipp==3.7.0
$ ape --version
0.1.0b5

$ ape plugins list
Installed Plugins:
  solidity        0.1.0b5
  vyper           0.1.0b6

What went wrong?

I have a ape-config.yaml that looks like the following:

contracts_folder: contracts
dependencies:
    - name: aave
      github: aave/protocol-v2
      version: 1.0.1
solidity:
    import_remapping:
        - "@aave=aave/1.0.1"

I'm trying to pull from the aave github repo of course.

I have an interface that looks like the following:

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import {ILendingPoolAddressesProvider} from '@aave/contracts/interfaces/ILendingPoolAddressesProvider.sol';
import {DataTypes} from '@aave/contracts/protocol/libraries/types/DataTypes.sol';

interface ILendingPool {
// rest of the contract...

When I run ape compile, I get this error:

ERROR: (ProjectError) Unknown version '1.0.1' for repo 'protocol-v2'.

It looks like I'm passing something wrong in my ape-config.yaml but It seems to match the docs?

However, I can see that tag here

How can it be fixed?

Not sure yet.

antazoey commented 2 years ago

@PatrickAlphaC Currently, we use the Github releases API to download version-specified releases, we don't clone the tag. However, I think we can try to support this, as we already support branch-based dependencies on Github.

As a temporary workaround, you can use branch: master and see if that works for getting the master code. I also wonder if you put the git tag like branch: <tag> if that would work but not sure on that one.

Anyway, thanks for reporting! We will get this working for you.

PatrickAlphaC commented 2 years ago

Thanks! Looks like this was able to get the download going (:

dependencies:
    - name: aave
      github: aave/protocol-v2
      branch: 1.0.1
solidity:
    import_remapping:
        - "@aave=aave/1.0.1"

But now I'm getting:

INFO: Cloning branch '1.0.1' from 'protocol-v2'.
 99%|█████████████████████████████████████████████████████████████████████████▎| 985/994 [00:00<00:00, 31010.15it/s]Traceback (most recent call last):
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/bin/ape", line 8, in <module>
    sys.exit(cli())
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/ape/_cli.py", line 40, in invoke
    return super().invoke(ctx)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/ape_compile/_cli.py", line 50, in cli
    contract_types = cli_ctx.project.load_contracts(file_paths=file_paths, use_cache=use_cache)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/ape/managers/project.py", line 609, in load_contracts
    self._load_dependencies()
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/ape/managers/project.py", line 683, in _load_dependencies
    return {d.name: d.extract_manifest() for d in self.config.dependencies}
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/ape/managers/project.py", line 683, in <dictcomp>
    return {d.name: d.extract_manifest() for d in self.config.dependencies}
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/ape/managers/project.py", line 225, in extract_manifest
    github_client.clone_repo(self.github, temp_project_path, branch=self.branch)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/ape/utils.py", line 456, in clone_repo
    clone = pygit2.clone_repository(
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/pygit2/__init__.py", line 222, in clone_repository
    payload.check_error(err)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/pygit2/callbacks.py", line 93, in check_error
    check_error(error_code)
  File "/Users/patrick/code/aave_apeworx_py/ape-venv/lib/python3.9/site-packages/pygit2/errors.py", line 56, in check_error
    raise KeyError(message)
KeyError: "reference 'refs/remotes/origin/1.0.1' not found"
 99%|███████████████████████████████████████████████████████████████████████████▎| 985/994 [00:02<00:00, 350.83it/s]
antazoey commented 2 years ago

So currently, we don't support compiling the Aave protocol-2 project. Reason:

That is a Hardhat project. Sometimes, however, it still works. In this case, though, some of the dependency mappings that happen in the package.json are not mapped correctly when it tries to compile the dependency.

Good news Is that we actually have a ProjectAPI and a DependencyAPI that one could theoretically implement an NPM dependency resolver and a Hardhat project adapter implementation.

antazoey commented 2 years ago

Other alternatives I can think of for the time being:

  1. Fork the project and make it ape-friendly
  2. Copy in the source files you need to your project
PatrickAlphaC commented 2 years ago

Gotcha, thanks! For the moment I'll wait for full github / nodejs project compatibility :)

Thank you!

antazoey commented 2 years ago

I have part of this fixed via #507 which will allow you to ignore files in the protocol-2 dependency that are problematic, which currently are everything in mocks/ and deployments/ (I hope you don't need those at this time).

There is one other solidity stack exception related bug that still occurs that requires further investigation

antazoey commented 2 years ago

Further fixes were done to be able to compile Aave: https://github.com/ApeWorX/ape-solidity/pull/26

PatrickAlphaC commented 2 years ago

I'll try this out later!

antazoey commented 2 years ago

Closing optimistically! @PatrickAlphaC let us know if this needs to be re-opened?

PatrickAlphaC commented 2 years ago

I'll have to try this out later.. but I'll let you know!