banteg / multicall.py

aggregate results of multiple smart contract calls into one
MIT License
246 stars 106 forks source link

Multicall() does not work in pip version 0.7.9 #85

Closed tudorelu closed 5 months ago

tudorelu commented 1 year ago

Issue with: multicall==0.7.9

I create a Call (programmatically) which works if called it by itself. It calls the token0() function from a UniswapPair-like contract, returns the address of the base token for that pair .

Here are its details:

# on optimism mainnet

>>> c.target
'0xf4d40ebCBf7063D4ff56C6Df0179a86287C648dE'

>>> c.function
'token0()(address)'

>>> c.data
b'\r\xfe\x16\x81'

>>> c.args
[]

>>> c()
returns: [('0xf4d40ebCBf7063D4ff56C6Df0179a86287C648dE_base', None)]
decoded: ('0xb6599bd362120dc70d48409b8a08888807050700',)
{'0xf4d40ebCBf7063D4ff56C6Df0179a86287C648dE_base': '0xb6599bd362120dc70d48409b8a08888807050700'}

But does not work when called as part of a Multicall:

>>> Multicall([c],  _w3=w3)()
coroutine 0 started       
# and just stays here
raychangXrex commented 11 months ago

same issue here @0.8.1

zcc19960910 commented 10 months ago

Because the code is deadlocked!

multicall.py and call.py all use

async with _get_semaphore(), so you must remove call.py

then it is ok!!!

Python official example: https://docs.python.org/zh-cn/3/library/asyncio-sync.html?highlight=semaphore#asyncio.Semaphore

sem = asyncio.Semaphore()

await sem.acquire() try:

work with shared resource

finally: sem.release()

BobTheBuidler commented 5 months ago

fixed in #95