Code Monkey home page Code Monkey logo

Comments (8)

SHAKOTN avatar SHAKOTN commented on September 26, 2024

I second this. Experiencing same issue on my laptop

from ape-alchemy.

gosuto-inzasheru avatar gosuto-inzasheru commented on September 26, 2024

more findings:
Contract("0x4d224452801ACEd8B2F0aebE155379bb5D594381").Transfer.query("transaction_hash", start_block=15000000) runs fine when connecting through geth uri, but when running that with default provider set to alchemy, again it freezes with no output/errors.

is there an inherent different way of connecting through ape-alchemy than through the normal, non-plugin geth way? i guess especially for get_contract_logs, does it behave differently using this plugin?

edit: ok wow looks like it came through after all! just suuuuper slow

from ape-alchemy.

fubuloubu avatar fubuloubu commented on September 26, 2024

@gosuto-inzasheru I believe these are symptoms of ApeWorX/ape#1119, just with a different provider causing the issue. when you don't restrict queries by block number, currently it queries all possible blocks for events in each transaction which is.... extremely slow, yes. will definitely want to refactor it to using filters and paging to make it speed up

@Ninjagod1251 let's confirm this is indeed the same behavior, and then we can close this in favor of the ape core issue because I don't think it's alchemy causing the problem here

from ape-alchemy.

gosuto-inzasheru avatar gosuto-inzasheru commented on September 26, 2024

ApeWorX/ape#1119 is definitely related, but i believe there is something inherently different about the way a .query gets made when ape-alchemy is installed:

$ ape plugins list   
Installed Plugins:
  arbitrum     0.5.1
  etherscan    0.5.4
$ ape console -v INFO

In [1]: import timeit;timeit.timeit('from ape import Contract;Contract("0x4d224452801ACEd8B2F0aeb
   ...: E155379bb5D594381").Transfer.query("transaction_hash", start_block=15000000)', number=3)
INFO: Cache database has not been initialized
Out[1]: 375.95413874601945
$ ape plugins list
Installed Plugins:
  alchemy      0.5.3
  arbitrum     0.5.1
  etherscan    0.5.4
$ ape console -v INFO

In [1]: import timeit;timeit.timeit('from ape import Contract;Contract("0x4d224452801ACEd8B2F0aeb
   ...: E155379bb5D594381").Transfer.query("transaction_hash", start_block=15000000)', number=3)
INFO: Cache database has not been initialized
Out[1]: 3181.283465335029

from ape-alchemy.

fubuloubu avatar fubuloubu commented on September 26, 2024

ApeWorX/ape#1119 is definitely related, but i believe there is something inherently different about the way a .query gets made when ape-alchemy is installed:

$ ape plugins list   
Installed Plugins:
  arbitrum     0.5.1
  etherscan    0.5.4
$ ape console -v INFO

In [1]: import timeit;timeit.timeit('from ape import Contract;Contract("0x4d224452801ACEd8B2F0aeb
   ...: E155379bb5D594381").Transfer.query("transaction_hash", start_block=15000000)', number=3)
INFO: Cache database has not been initialized
Out[1]: 375.95413874601945
$ ape plugins list
Installed Plugins:
  alchemy      0.5.3
  arbitrum     0.5.1
  etherscan    0.5.4
$ ape console -v INFO

In [1]: import timeit;timeit.timeit('from ape import Contract;Contract("0x4d224452801ACEd8B2F0aeb
   ...: E155379bb5D594381").Transfer.query("transaction_hash", start_block=15000000)', number=3)
INFO: Cache database has not been initialized
Out[1]: 3181.283465335029

This is very strange indeed! Are you using alchemy as your default network when executing example 2?

from ape-alchemy.

gosuto-inzasheru avatar gosuto-inzasheru commented on September 26, 2024

indeed, in both examples my ape config looks like this:

ethereum:
  default_network: mainnet
  mainnet:
    default_provider: alchemy
geth:
  ethereum:
    mainnet:
      uri: https://eth-mainnet.g.alchemy.com/v2/XXX

which in the first run gives ERROR: Failed setting default provider: Provider 'alchemy' not found in network 'mainnet'. right before connecting to the geth configured url. in the second run it connects to alchemy successfully (using the WEB3_ETHEREUM_MAINNET_ALCHEMY_API_KEY=XXX in my .env).

from ape-alchemy.

fubuloubu avatar fubuloubu commented on September 26, 2024

Gotcha, okay that makes more sense

from ape-alchemy.

fubuloubu avatar fubuloubu commented on September 26, 2024

Ah, reading this now it seems like this provider either needs to override Web3Provider.get_contract_logs to use the 2k block chunks:

https://github.com/ApeWorX/ape/blob/79a552f61080aff891bad4bf965bc96fca832c6c/src/ape/api/providers.py#L1020

or change block_page_size: int = 100 to block_page_size: int = 2000

from ape-alchemy.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.