From de14cea6a681b5248ed70ec92a09bf64d1b03364 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Sun, 15 Dec 2024 14:14:54 -0400 Subject: [PATCH] feat: ttl_cache on _extract_abi_data (#856) * feat: ttl_cache on _extract_abi_data * chore: `black .` --------- Co-authored-by: github-actions[bot] --- y/contracts.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/y/contracts.py b/y/contracts.py index d2c683080..d9bf3c6e2 100644 --- a/y/contracts.py +++ b/y/contracts.py @@ -44,6 +44,7 @@ from brownie.network.state import _get_deployment from brownie.typing import AccountsType from brownie.utils import color +from cachetools.func import ttl_cache from checksum_dict import ChecksumAddressSingletonMeta from hexbytes import HexBytes from msgspec.json import decode @@ -935,6 +936,8 @@ def _squeeze(contract: Contract) -> Contract: return contract +# we loosely cache this so we don't have to repeatedly fetch abis for commonly used proxy implementations +@ttl_cache(maxsize=1000, ttl=60 * 60) @eth_retry.auto_retry def _extract_abi_data(address: Address): """ @@ -1064,9 +1067,8 @@ def _resolve_proxy(address) -> Tuple[str, List]: return name, abi -@alru_cache( - ttl=300 -) # we loosely cache this so we don't have to repeatedly fetch abis for commonly used proxy implementations +# we loosely cache this so we don't have to repeatedly fetch abis for commonly used proxy implementations +@alru_cache(maxsize=1000, ttl=300) async def _extract_abi_data_async(address: Address): """ Extract ABI data for a contract from the blockchain explorer.