apeworx / ape-alchemy Goto Github PK
View Code? Open in Web Editor NEWAlchemy network provider plugin for the Ape Framework
Home Page: https://www.apeworx.io/
Alchemy network provider plugin for the Ape Framework
Home Page: https://www.apeworx.io/
$ ape --version
0.6.7
$ ape plugins list
alchemy 0.6.1
I'm trying to replicate banteg's work here: https://gist.github.com/banteg/dcf6082ff7fc6ad51ce220146f29d9ff
ape console --network 'ethereum:mainnet:alchemy
uniswap = Contract('0x3416cF6C708Da44DB2624D63ea0AAef7113527C6')
Results
ERROR: (ChainError) Failed to get contract type for address '0x3416cF6C708Da44DB2624D63ea0AAef7113527C6'
Support other alchemy networks such as Fantom
Similar to this:
ApeWorX/ape-infura#24
Include links to any open issues that must be resolved before this feature can be implemented.
Add method documentation for the plugin
Setup and add method docs using sphinx
None
alchemy has a special API we could use or querying to save a request
https://docs.alchemy.com/reference/alchemy-gettransactionreceipts
Describe the syntax and semantics of how you would like to see this feature implemented. The more detailed the better!
Remember, your feature is much more likely to be included if it does not involve any breaking changes.
Include links to any open issues that must be resolved before this feature can be implemented.
Alchemy has announced they added a custom RPC to submit transactions via Flashbots
https://twitter.com/AlchemyPlatform/status/1529873958492729348
Add support for these new methods:
None
Allow configuration by network similar to geth provider.
Something like this would be cool:
alchemy:
ethereum:
mainnet:
uri: https://eth-rinkeby.alchemyapi.io/v2/API_KEY
Or if you feel strongly about using keys instead of JSON-RPC URIs:
alchemy:
ethereum:
mainnet:
api-key: API_KEY
Or maybe both?
There's probably some security concern here. It's not ideal if these keys are committed to public repos for an Ape project. However, I think that should be a decision for users to make (they may encrypt the config in their worfklow or use private repos and share keys between the team for dev purposes).
Not a hard dep, but I think this would gel well with a global config: ApeWorX/ape#379.
ape
and plugin versions:$ ape --version
0.6.21
$ ape plugins list
Installed Plugins
alchemy 0.6.5
foundry 0.6.17
vyper 0.6.11
Trying to use this with a free tier Alchemy key and can't make it usable.
[...snip...]
File "/path/to/venv/lib/python3.11/site-packages/ape/contracts/base.py", line 641, in range
yield from self.query_manager.query(contract_event_query) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/venv/lib/python3.11/site-packages/ape/api/providers.py", line 1392, in get_contract_logs
for page in pool.map(fetch_log_page, block_ranges):
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 619, in result_iterator
yield _result_or_cancel(fs.pop())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 317, in _result_or_cancel
return fut.result(timeout)
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/venv/lib/python3.11/site-packages/ape/api/providers.py", line 1388, in fetch_log_page
logs = self._get_logs(page_filter.dict(), raw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/venv/lib/python3.11/site-packages/ape/api/providers.py", line 1399, in _get_logs
return self._make_request("eth_getLogs", [filter_params])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/venv/lib/python3.11/site-packages/ape_alchemy/provider.py", line 200, in _make_request
raise cls(message) from err
ape_alchemy.exceptions.AlchemyProviderError: Your app has exceeded its compute units per second capacity. If you have retries enabled, you can safely ignore this message. If not, check out https://docs.alchemy.com/reference/throughput
I think it's critical to have HTTP retries (probably with a backoff) in this lib. This isn't a recoverable error or anything I can do about other than upgrading my Alchemy subscription.
Should be noted that Alchemy's own SDK implements retries and they recommend doing so if you implement your own provider.
I saw #35 which may be a path forward but it looks a bit stalled.
Alchemy supports grip compression for reducing method latency for large requests
https://docs.alchemy.com/docs/how-to-enable-compression-to-speed-up-json-rpc-blockchain-requests
Add it to the header. May need to make a heuristic on expected response size to include this or not
N/A
WEB3_ETHEREUM_MAINNET_ALCHEMY_PRPJECT_ID is spelled wrong, should be
WEB3_ETHEREUM_MAINNET_ALCHEMY_PROJECT_ID
:D
ape
and plugin versions:$ ape --version
0.5.5
$ ape plugins list
Installed Plugins:
arbitrum 0.5.1
alchemy 0.5.2
etherscan 0.5.4
Please include information like:
running the following in console gets stuck for me (no more output, no errors) using alchemy as my default provider:
Contract('0x4d224452801ACEd8B2F0aebE155379bb5D594381').Transfer.query('*', start_block=14204533)
ethereum:
default_network: mainnet
mainnet:
default_provider: alchemy
however, if i connect to alchemy directly (ie without using ape-alchemy
):
geth:
ethereum:
mainnet:
uri: https://eth-mainnet.g.alchemy.com/v2/XXX
i get the following error back:
ProviderError: Log response size exceeded. You can make eth_getLogs requests with up to a 2K block range and no limit on the response size, or you can request any block range with a cap of 10K logs in the response. Based on your parameters and the response size limit, this block range should work: [0xdbb82d, 0xdbca64]
(note that if i pass stop_block=14404196
, as proposed by the error, i do get results back for both the ape-alchemy
and the geth
approach)
feels to me the error should be raised all the way when using ape-alchemy
, this in order to prevent endless waiting and not knowing what went wrong.
Goerli and such still need the PoA middleware when accessing any blocks before the merge.
Please include information like:
Fill this in if you have ideas on how the bug could be fixed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.