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
and plugin versions:$ ape --version
0.8.5
$ ape plugins list
Installed Plugins
alchemy 0.8.0
arbitrum 0.8.0
aws 0.8.0a3
base 0.8.0
etherscan 0.8.0
foundry 0.8.0
optimism 0.8.0
solidity 0.8.2
In ape console
, private transactions sent through Alchemy do not immediately return a transaction receipt even when required_confirmations=0
. For our silverback bot, example call to our contract
In [12]: arbitrageur.execute(params, sender=acc, required_confirmations=0, private=True)
stalls for significant amount of time without returning and continuing to the next console input line. The private transaction does go through successfully though eventually.
Seems like in private transactions there is a timeout
parameter set to 25 blocks always for each transaction. Maybe this is the cause of the issue?
Would expect required_confirmations=0
to override any potential timeout.
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
Add method documentation for the plugin
Setup and add method docs using sphinx
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.
Provide a simple overview of what you wish to see added. Please include:
add the option to pass multiple API keys
Rate limit/ Distribute network requests
Similar PR opened: ApeWorX/ape-infura#88
N/A
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.
Provide a simple overview of what you wish to see added. Please include:
What you are trying to do
Currently rollups provide more information on the output of transactions in receipt, :
gasUsedForL1
from arbitrum receipts
l1BlobBaseFeeScalar
, l1GasUsed
, l1Fee
, l1GasPrice
,l1BaseFeeScalar
, l1BlobBaseFee
for optimism
Why Ape's current functionality is inadequate to address your goal
Ape does not retrieve the extra data available in these rollups
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.
Example:
import web3 as W3
import json
rpc = "https://arb-mainnet.g.alchemy.com/v2/XXXXXXXXXXXXXXXXX"
w3 = W3.Web3(W3.HTTPProvider(rpc))
txHash = "0x2bb34d01b746c0ac6fddb405be3201ca1071cff0ef09eb03ebf069b2f3b2898a"
tx = w3.eth.get_transaction(txHash)
receipt = w3.eth.get_transaction_receipt(txHash)
print(receipt.gasUsedForL1)
return
0x744c
While the ape version:
from ape import chain
txHash = "0x1ab9fe34ad920b6947f812924770d7068bce715cd193d82f9f2f6c3626a48b5a"
receipt = chain.get_receipt(txHash)
print(receipt.gasUsedForL1)
gives
*** ape.exceptions.ApeAttributeError: 'ArbitrumReceipt' object has no attribute 'gasUsedForL1'. Also checked extra(s) 'transaction'.
Incorporate a rollup_receipt: ReceiptAPI | None
which is a dictionary containing the rollup extra data available in standard l2/l3 receipts
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.
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.
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.
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.
as a performance improvement, we can use this feature for only getting the top level call and geting the return data that way:
tracerConfig - Object to specify configurations for the tracer
onlyTopCall - boolean Setting this to true will only trace the main (top-level) call and none of the sub-calls. This avoids extra processing for each call frame if only the top-level call info are required (useful for getting revertReason).
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
$ 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'
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.