Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use .stream_request() for calls #2471

Closed

Conversation

antazoey
Copy link
Member

What I did

This may help with large multicall responses, and I wasn't really seeing any perf or other downsides for small requests.

How I did it

How to verify it

Checklist

  • All changes are completed
  • Change is covered in tests
  • Documentation is complete

Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What sorts of practical tests has this been benchmarked with?

@fubuloubu
Copy link
Member

Ran into a problem with this one using Alchemy

File ~/.pyenv/versions/3.11.11/envs/uniswap-sdk/lib/python3.11/site-packages/ape/contracts/base.py:273, in ContractCallHandler.__call__(self, *args, **kwargs)
    270 selected_abi = _select_method_abi(self.abis, args)
    271 arguments = self.conversion_manager.convert_method_args(selected_abi, args)
--> 273 return ContractCall(
    274     abi=selected_abi,
    275     address=self.contract.address,
    276 )(*arguments, **kwargs)

File ~/.pyenv/versions/3.11.11/envs/uniswap-sdk/lib/python3.11/site-packages/ape/contracts/base.py:123, in ContractCall.__call__(self, *args, **kwargs)
    121 txn = self.serialize_transaction(*args, **kwargs)
    122 txn.chain_id = self.provider.network.chain_id
--> 123 raw_output = self.provider.send_call(txn, **kwargs)
    124 output = self.provider.network.ecosystem.decode_returndata(
    125     self.abi,
    126     raw_output,
    127 )
    129 if not isinstance(output, (list, tuple)):

File ~/.pyenv/versions/3.11.11/envs/uniswap-sdk/lib/python3.11/site-packages/ape_ethereum/provider.py:706, in Web3Provider.send_call(self, txn, block_id, state, **kwargs)
    704 needs_trace = track_gas or track_coverage or show_gas or show_trace
    705 if not needs_trace:
--> 706     return self._eth_call(arguments, raise_on_revert=raise_on_revert, skip_trace=skip_trace)
    708 # The user is requesting information related to a call's trace,
    709 # such as gas usage data.
    710 
    711 # When looking at gas, we cannot use token symbols in enrichment.
    712 # Else, the table is difficult to understand.
    713 use_symbol_for_tokens = track_gas or show_gas

File ~/.pyenv/versions/3.11.11/envs/uniswap-sdk/lib/python3.11/site-packages/ape_ethereum/provider.py:792, in Web3Provider._eth_call(self, arguments, raise_on_revert, skip_trace)
    789 if "error" in result:
    790     raise ProviderError(result["error"]["message"])
--> 792 return HexBytes(result)

File ~/.pyenv/versions/3.11.11/envs/uniswap-sdk/lib/python3.11/site-packages/hexbytes/main.py:33, in HexBytes.__new__(cls, val)
     32 def __new__(cls: Type[bytes], val: BytesLike) -> "HexBytes":
---> 33     bytesval = to_bytes(val)
     34     return cast(HexBytes, super().__new__(cls, bytesval))

File ~/.pyenv/versions/3.11.11/envs/uniswap-sdk/lib/python3.11/site-packages/hexbytes/_utils.py:32, in to_bytes(val)
     30     return bytes(val)
     31 else:
---> 32     raise TypeError(f"Cannot convert {val!r} of type {type(val)} to bytes")

TypeError: Cannot convert <generator object Web3Provider.stream_request at 0x7f125b4085e0> of type <class 'generator'> to bytes

@antazoey antazoey closed this Jan 24, 2025
@antazoey antazoey deleted the refactor/use-stream-request-for-calls branch January 24, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants