diff --git a/aea/crypto/base.py b/aea/crypto/base.py index 6676b39308..e45c9e764b 100644 --- a/aea/crypto/base.py +++ b/aea/crypto/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2021-2023 Valory AG +# Copyright 2021-2024 Valory AG # Copyright 2018-2019 Fetch.AI Limited # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -529,6 +529,32 @@ def get_transaction_transfer_logs( :param target_address: optional address to filter transfer events to just those that affect it """ + @abstractmethod + def filter_event( + self, + event: Any, + match_single: Dict[str, Any], + match_any: Dict[str, Any], + to_block: int, + from_block: int, + batch_size: int, + max_retries: int, + reduce_factor: float, + timeout: int, + ) -> Optional[JSONLike]: + """Filter an event using batching to avoid RPC timeouts. + + :param event: the event to filter for. + :param match_single: the filter parameters with value checking against the event abi. It allows for defining a single match value. + :param match_any: the filter parameters with value checking against the event abi. It allows for defining multiple match values. + :param to_block: the block to which to filter. + :param from_block: the block from which to start filtering. + :param batch_size: the blocks' batch size of the filtering. + :param max_retries: the maximum number of retries. + :param reduce_factor: the percentage by which the batch size is reduced in case of a timeout. + :param timeout: a timeout in seconds to interrupt the operation in case the RPC request hangs. + """ + class FaucetApi(ABC): """Interface for testnet faucet APIs.""" diff --git a/docs/api/crypto/base.md b/docs/api/crypto/base.md index 0faf1787e4..1aee30a6bb 100644 --- a/docs/api/crypto/base.md +++ b/docs/api/crypto/base.md @@ -808,6 +808,32 @@ Get all transfer events derived from a transaction. - `tx_hash`: the transaction hash - `target_address`: optional address to filter transfer events to just those that affect it + + +#### filter`_`event + +```python +@abstractmethod +def filter_event(event: Any, match_single: Dict[str, Any], + match_any: Dict[str, Any], to_block: int, from_block: int, + batch_size: int, max_retries: int, reduce_factor: float, + timeout: int) -> Optional[JSONLike] +``` + +Filter an event using batching to avoid RPC timeouts. + +**Arguments**: + +- `event`: the event to filter for. +- `match_single`: the filter parameters with value checking against the event abi. It allows for defining a single match value. +- `match_any`: the filter parameters with value checking against the event abi. It allows for defining multiple match values. +- `to_block`: the block to which to filter. +- `from_block`: the block from which to start filtering. +- `batch_size`: the blocks' batch size of the filtering. +- `max_retries`: the maximum number of retries. +- `reduce_factor`: the percentage by which the batch size is reduced in case of a timeout. +- `timeout`: a timeout in seconds to interrupt the operation in case the RPC request hangs. + ## FaucetApi Objects diff --git a/docs/api/plugins/aea_ledger_cosmos/cosmos.md b/docs/api/plugins/aea_ledger_cosmos/cosmos.md index d4a39798e3..676bcd575c 100644 --- a/docs/api/plugins/aea_ledger_cosmos/cosmos.md +++ b/docs/api/plugins/aea_ledger_cosmos/cosmos.md @@ -972,6 +972,31 @@ This operation is not supported for cosmos. - `raise_on_try`: whether the method will raise or log on error. - `kwargs`: the keyword arguments. + + +#### filter`_`event + +```python +def filter_event(event: Any, match_single: Dict[str, Any], + match_any: Dict[str, Any], to_block: int, from_block: int, + batch_size: int, max_retries: int, reduce_factor: float, + timeout: int) -> Optional[JSONLike] +``` + +Filter an event using batching to avoid RPC timeouts. + +**Arguments**: + +- `event`: the event to filter for. +- `match_single`: the filter parameters with value checking against the event abi. It allows for defining a single match value. +- `match_any`: the filter parameters with value checking against the event abi. It allows for defining multiple match values. +- `to_block`: the block to which to filter. +- `from_block`: the block from which to start filtering. +- `batch_size`: the blocks' batch size of the filtering. +- `max_retries`: the maximum number of retries. +- `reduce_factor`: the percentage by which the batch size is reduced in case of a timeout. +- `timeout`: a timeout in seconds to interrupt the operation in case the RPC request hangs. + ## CosmosApi Objects diff --git a/docs/api/plugins/aea_ledger_ethereum/ethereum.md b/docs/api/plugins/aea_ledger_ethereum/ethereum.md index 6c25cf2bc9..ab2a481665 100644 --- a/docs/api/plugins/aea_ledger_ethereum/ethereum.md +++ b/docs/api/plugins/aea_ledger_ethereum/ethereum.md @@ -119,6 +119,27 @@ def get_gas_price_strategy( Get the gas price strategy. + + +#### rpc`_`call`_`with`_`timeout + +```python +def rpc_call_with_timeout(func: Callable, timeout: int) -> Any +``` + +Execute an RPC call with a timeout. + + + +#### match`_`items + +```python +def match_items(filter_: EventFilterBuilder, event_name: str, + method_to_matches: Dict[str, Dict[str, Any]]) +``` + +Build filters for the given match dictionary. + ## SignedTransactionTranslator Objects @@ -942,6 +963,52 @@ This operation is not supported for ethereum. Please use the ethereum_flashbots - `raise_on_try`: whether the method will raise or log on error - `kwargs`: the keyword arguments. + + +#### batch`_`filter`_`wrapper + +```python +def batch_filter_wrapper(event: ContractEvent, match_single: Dict[str, Any], + match_any: Dict[str, Any], to_block: BlockNumber, + from_block: BlockNumber) -> Any +``` + +A wrapper for a single batch's event filtering operation. + + + +#### filter`_`event + +```python +def filter_event(event: ContractEvent, + match_single: Dict[str, Any], + match_any: Dict[str, Any], + to_block: BlockNumber, + from_block: BlockNumber = 0, + batch_size: int = 5_000, + max_retries: int = 5, + reduce_factor: float = 0.25, + timeout: int = 5 * 60) -> Optional[JSONLike] +``` + +Filter an event using batching to avoid RPC timeouts. + +**Arguments**: + +- `event`: the event to filter for. +- `match_single`: the filter parameters with value checking against the event abi. It allows for defining a single match value. +- `match_any`: the filter parameters with value checking against the event abi. It allows for defining multiple match values. +- `to_block`: the block to which to filter. +- `from_block`: the block from which to start filtering. +- `batch_size`: the blocks' batch size of the filtering. +- `max_retries`: the maximum number of retries. +- `reduce_factor`: the percentage by which the batch size is reduced in case of a timeout. +- `timeout`: a timeout in seconds to interrupt the operation in case the RPC request hangs. + +**Returns**: + +the filtering result. + ## EthereumFaucetApi Objects diff --git a/docs/api/plugins/aea_ledger_fetchai/fetchai.md b/docs/api/plugins/aea_ledger_fetchai/fetchai.md index b9bfaa5134..e5abafa49f 100644 --- a/docs/api/plugins/aea_ledger_fetchai/fetchai.md +++ b/docs/api/plugins/aea_ledger_fetchai/fetchai.md @@ -122,6 +122,31 @@ This operation is not supported for fetchai. - `raise_on_try`: whether the method will raise or log on error. - `kwargs`: the keyword arguments. + + +#### filter`_`event + +```python +def filter_event(event: Any, match_single: Dict[str, Any], + match_any: Dict[str, Any], to_block: int, from_block: int, + batch_size: int, max_retries: int, reduce_factor: float, + timeout: int) -> Optional[JSONLike] +``` + +Filter an event using batching to avoid RPC timeouts. + +**Arguments**: + +- `event`: the event to filter for. +- `match_single`: the filter parameters with value checking against the event abi. It allows for defining a single match value. +- `match_any`: the filter parameters with value checking against the event abi. It allows for defining multiple match values. +- `to_block`: the block to which to filter. +- `from_block`: the block from which to start filtering. +- `batch_size`: the blocks' batch size of the filtering. +- `max_retries`: the maximum number of retries. +- `reduce_factor`: the percentage by which the batch size is reduced in case of a timeout. +- `timeout`: a timeout in seconds to interrupt the operation in case the RPC request hangs. + ## FetchAIFaucetApi Objects diff --git a/docs/api/plugins/aea_ledger_solana/solana.md b/docs/api/plugins/aea_ledger_solana/solana.md index a5f82e6af2..caaa9b02cd 100644 --- a/docs/api/plugins/aea_ledger_solana/solana.md +++ b/docs/api/plugins/aea_ledger_solana/solana.md @@ -559,3 +559,28 @@ Get all transfer events derived from a transaction. the transfer logs + + +#### filter`_`event + +```python +def filter_event(event: Any, match_single: Dict[str, Any], + match_any: Dict[str, Any], to_block: int, from_block: int, + batch_size: int, max_retries: int, reduce_factor: float, + timeout: int) -> Optional[JSONLike] +``` + +Filter an event using batching to avoid RPC timeouts. + +**Arguments**: + +- `event`: the event to filter for. +- `match_single`: the filter parameters with value checking against the event abi. It allows for defining a single match value. +- `match_any`: the filter parameters with value checking against the event abi. It allows for defining multiple match values. +- `to_block`: the block to which to filter. +- `from_block`: the block from which to start filtering. +- `batch_size`: the blocks' batch size of the filtering. +- `max_retries`: the maximum number of retries. +- `reduce_factor`: the percentage by which the batch size is reduced in case of a timeout. +- `timeout`: a timeout in seconds to interrupt the operation in case the RPC request hangs. + diff --git a/docs/package_list.md b/docs/package_list.md index db1f2b5939..5fac7c00ff 100644 --- a/docs/package_list.md +++ b/docs/package_list.md @@ -14,7 +14,7 @@ | contract/fetchai/erc1155/0.22.0 | `bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4` | | connection/fetchai/gym/0.19.0 | `bafybeicqqvl4tt3qbulnkoffciagmfd6p3hxxi3i2mrrqtnbycv757pn6y` | | connection/fetchai/stub/0.21.0 | `bafybeibybboiwgklfiqpkkcw6rwj65s5jalzfzf6mh6fstxdlt6habzwvy` | -| connection/valory/ledger/0.19.0 | `bafybeic3ft7l7ca3qgnderm4xupsfmyoihgi27ukotnz7b5hdczla2enya` | +| connection/valory/ledger/0.19.0 | `bafybeig7woeog4srdby75hpjkmx4rhpkzncbf4h2pm5r6varsp26pf2uhu` | | connection/valory/http_server/0.22.0 | `bafybeihpgu56ovmq4npazdbh6y6ru5i7zuv6wvdglpxavsckyih56smu7m` | | connection/valory/p2p_libp2p/0.1.0 | `bafybeic2u7azbwjny2nhaltqnbohlvysx3x6ectzbege7sxwrbzcz4lcma` | | connection/valory/p2p_libp2p_client/0.1.0 | `bafybeid3xg5k2ol5adflqloy75ibgljmol6xsvzvezebsg7oudxeeolz7e` | @@ -26,12 +26,12 @@ | skill/fetchai/error_test_skill/0.1.0 | `bafybeihsbtlpe7h6fsvoxban5rilkmwviwkokul5cqym6atoolirontiyu` | | skill/fetchai/gym/0.20.0 | `bafybeie7y2fsxfuhsqxqcaluo5exskmrm5q3a6e2hfcskcuvzvxjjhijh4` | | skill/fetchai/http_echo/0.20.0 | `bafybeicfiri2juaqh3azeit3z3rf44kgxdo6oj4lgxjgvnowq6m7j47qrm` | -| skill/fetchai/erc1155_client/0.28.0 | `bafybeiauu446slcix3khzdqlgbt5ab323ik5fc3s7s4lxoanecrewfktju` | -| skill/fetchai/erc1155_deploy/0.30.0 | `bafybeifgsf5wp6lb6ztkf7orbhv2wc7b4mrxosgyt6yrnjclmssmsqru2e` | +| skill/fetchai/erc1155_client/0.28.0 | `bafybeigwh2lnnvaimjhrf6eibhy7wohfokvkwoabjr5t2vhyrzqmlu4tg4` | +| skill/fetchai/erc1155_deploy/0.30.0 | `bafybeiepibtz2uioupucjtmo4n6dyxnx2m26bausegojmw6su6mtjxkvpe` | | skill/fetchai/error/0.17.0 | `bafybeicboomvykqhel3otyv4qg5t3hzpo6kmn5bk4ljluithhuieu7flsm` | | skill/fetchai/fipa_dummy_buyer/0.2.0 | `bafybeidgso7lo5ay44mbxsp3lxilrgeek3ye44e6wus2ayq6kyxfvc3vjm` | -| skill/fetchai/generic_buyer/0.26.0 | `bafybeif56kwbxbtuhjzd7dohivfdzlkvgprnugymlyizazudzkded3nblm` | -| skill/fetchai/generic_seller/0.27.0 | `bafybeic6sgtjyd5j4xqwuruijtqnl22y3sfdbf3mnrkchu2x4bx7eo2t6e` | +| skill/fetchai/generic_buyer/0.26.0 | `bafybeidnlxecybia3nkvakemei74z7vnuszql4pmne5xiuxypjmklb27ei` | +| skill/fetchai/generic_seller/0.27.0 | `bafybeihs37oub5qnwybyrkfxlqnjbjcfjqfwtwmdogtsbexo3nguhdsnc4` | | skill/fetchai/task_test_skill/0.1.0 | `bafybeidv77u2xl52mnxakwvh7fuh46aiwfpteyof4eaptfd4agoi6cdble` | | agent/fetchai/error_test/0.1.0 | `bafybeiecm675ndzbh35jkejtxn4ughoutztltjhgwzfbp57okabedjmnpq` | | agent/fetchai/gym_aea/0.25.0 | `bafybeibzn3qomqmkaksgpd3gn6aijffvvw7rojswhoytiovohuc737fvfm` | diff --git a/plugins/aea-ledger-cosmos/aea_ledger_cosmos/cosmos.py b/plugins/aea-ledger-cosmos/aea_ledger_cosmos/cosmos.py index 84fdc8d11f..04a31dc054 100644 --- a/plugins/aea-ledger-cosmos/aea_ledger_cosmos/cosmos.py +++ b/plugins/aea-ledger-cosmos/aea_ledger_cosmos/cosmos.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2021-2023 Valory AG +# Copyright 2021-2024 Valory AG # Copyright 2018-2019 Fetch.AI Limited # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -1563,6 +1563,34 @@ def send_signed_transactions( f"Sending a bundle of transactions is not supported for the {self.identifier} plugin" ) + def filter_event( + self, + event: Any, + match_single: Dict[str, Any], + match_any: Dict[str, Any], + to_block: int, + from_block: int, + batch_size: int, + max_retries: int, + reduce_factor: float, + timeout: int, + ) -> Optional[JSONLike]: + """Filter an event using batching to avoid RPC timeouts. + + :param event: the event to filter for. + :param match_single: the filter parameters with value checking against the event abi. It allows for defining a single match value. + :param match_any: the filter parameters with value checking against the event abi. It allows for defining multiple match values. + :param to_block: the block to which to filter. + :param from_block: the block from which to start filtering. + :param batch_size: the blocks' batch size of the filtering. + :param max_retries: the maximum number of retries. + :param reduce_factor: the percentage by which the batch size is reduced in case of a timeout. + :param timeout: a timeout in seconds to interrupt the operation in case the RPC request hangs. + """ + raise NotImplementedError( # pragma: nocover + f"Custom events' filtering is not supported for the {self.identifier} plugin" + ) + class CosmosApi(_CosmosApi, CosmosHelper): """Class to interact with the Cosmos SDK via a HTTP APIs.""" diff --git a/plugins/aea-ledger-ethereum/aea_ledger_ethereum/ethereum.py b/plugins/aea-ledger-ethereum/aea_ledger_ethereum/ethereum.py index 4c4458536c..8220125cc2 100644 --- a/plugins/aea-ledger-ethereum/aea_ledger_ethereum/ethereum.py +++ b/plugins/aea-ledger-ethereum/aea_ledger_ethereum/ethereum.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2021-2023 Valory AG +# Copyright 2021-2024 Valory AG # Copyright 2018-2019 Fetch.AI Limited # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,6 +20,7 @@ """Ethereum module wrapping the public and private key cryptography and ledger api.""" +import concurrent.futures import decimal import json import logging @@ -39,11 +40,15 @@ from eth_account.messages import _hash_eip191_message, encode_defunct from eth_account.signers.local import LocalAccount from eth_keys import keys -from eth_typing import HexStr +from eth_typing import BlockNumber, HexStr from eth_utils.currency import from_wei, to_wei # pylint: disable=import-error from requests import HTTPError +from requests.exceptions import ReadTimeout as RequestsReadTimeoutError +from urllib3.exceptions import ReadTimeoutError as Urllib3ReadTimeoutError from web3 import HTTPProvider, Web3 +from web3._utils.events import EventFilterBuilder from web3._utils.request import SimpleCache +from web3.contract.contract import ContractEvent from web3.datastructures import AttributeDict from web3.exceptions import ContractLogicError, TransactionNotFound from web3.gas_strategies.rpc import rpc_gas_price_strategy @@ -76,6 +81,7 @@ SPEED_FAST = "fast" # safeLow, standard, fast POLYGON_GAS_ENDPOINT = "https://gasstation-mainnet.matic.network/v2" MAX_GAS_FAST = 1500 +RPC_CALL_MAX_WORKERS = 1 # How many blocks to consider for priority fee estimation FEE_HISTORY_BLOCKS = 10 @@ -126,6 +132,10 @@ # The tip increase is the minimum required of 10%. TIP_INCREASE = 1.1 +# the `web3` methods' names for logs filtering operations +MATCH_SINGLE = "match_single" +MATCH_ANY = "match_any" + def wei_to_gwei(number: Type[int]) -> Union[int, decimal.Decimal]: """Covert WEI to GWEI""" @@ -361,6 +371,50 @@ def gas_station_gas_price_strategy( return gas_station_gas_price_strategy +def rpc_call_with_timeout(func: Callable, timeout: int) -> Any: + """Execute an RPC call with a timeout.""" + + with concurrent.futures.ThreadPoolExecutor(RPC_CALL_MAX_WORKERS) as executor: + # submit the function with the RPC call to the executor + future = executor.submit(func) + + try: + # wait for the result with a timeout + data = future.result(timeout=timeout) + except TimeoutError: + # handle the case where the execution times out + err = f"The RPC didn't respond within {timeout} seconds." + return None, err + + # check if an error occurred + if isinstance(data, str): + # handle the case where the execution fails + return None, data + + return data, None + + +def match_items( + filter_: EventFilterBuilder, + event_name: str, + method_to_matches: Dict[str, Dict[str, Any]], +): + """Build filters for the given match dictionary.""" + for method, matches in method_to_matches.items(): + for arg, value in matches.items(): + arg_filter = filter_.args.get(arg, None) + if arg_filter is None: + raise ValueError( + f"There is no argument {arg!r} in the event {event_name}!" + ) + filtering_method = getattr(arg_filter, method, None) + if filtering_method is None: + raise ValueError( + f"There is no filtering method named {filtering_method}!" + ) + filtering_method(value) + + class SignedTransactionTranslator: """Translator for SignedTransaction.""" @@ -1543,6 +1597,95 @@ def send_signed_transactions( f"Sending a bundle of transactions is not supported for the {self.identifier} plugin" ) + def batch_filter_wrapper( + self, + event: ContractEvent, + match_single: Dict[str, Any], + match_any: Dict[str, Any], + to_block: BlockNumber, + from_block: BlockNumber, + ) -> Any: + """A wrapper for a single batch's event filtering operation.""" + + def batch_filter() -> Any: + """Filter events for a specific batch.""" + filter_ = event.build_filter() + filter_.fromBlock = from_block + filter_.toBlock = to_block + method_to_match_dict = { + MATCH_SINGLE: match_single, + MATCH_ANY: match_any, + } + match_items(filter_, event.event_name, method_to_match_dict) + + try: + return list(filter_.deploy(self.api).get_all_entries()) + except (Urllib3ReadTimeoutError, RequestsReadTimeoutError): + msg = ( + "The RPC timed out! This usually happens if the filtering is too wide. " + f"The service tried to filter the blocks in the range [{from_block} - {to_block}]. " + f"If this issue persists, please try lowering the batch size!" + ) + return msg + + return batch_filter + + def filter_event( + self, + event: ContractEvent, + match_single: Dict[str, Any], + match_any: Dict[str, Any], + to_block: BlockNumber, + from_block: BlockNumber = 0, + batch_size: int = 5_000, + max_retries: int = 5, + reduce_factor: float = 0.25, + timeout: int = 5 * 60, + ) -> Optional[JSONLike]: + """Filter an event using batching to avoid RPC timeouts. + + :param event: the event to filter for. + :param match_single: the filter parameters with value checking against the event abi. It allows for defining a single match value. + :param match_any: the filter parameters with value checking against the event abi. It allows for defining multiple match values. + :param to_block: the block to which to filter. + :param from_block: the block from which to start filtering. + :param batch_size: the blocks' batch size of the filtering. + :param max_retries: the maximum number of retries. + :param reduce_factor: the percentage by which the batch size is reduced in case of a timeout. + :param timeout: a timeout in seconds to interrupt the operation in case the RPC request hangs. + :return: the filtering result. + """ + + filtering_result = [] + n_retries = 0 + while from_block < to_block: + max_to_block = from_block + batch_size + to_block_adj = BlockNumber(min(max_to_block, to_block)) + filtering_operation = self.batch_filter_wrapper( + event, match_single, match_any, to_block_adj, from_block + ) + batch_result, err = rpc_call_with_timeout(filtering_operation, timeout) + if err is not None: + _default_logger.warning(err) + + if not batch_result and n_retries == max_retries: + err = "Skipping the filtering operation as the RPC is misbehaving." + raise ValueError(err) + + if not batch_result: + n_retries += 1 + keep_fraction = 1 - reduce_factor + batch_size = int(batch_size * keep_fraction) + _default_logger.warning( + f"Repeating this call with a decreased batch size of {batch_size}." + ) + continue + + from_block += batch_size + filtering_result.extend(batch_result) + + return dict(filtering_result=filtering_result) + class EthereumFaucetApi(FaucetApi): """Ethereum testnet faucet API.""" diff --git a/plugins/aea-ledger-fetchai/aea_ledger_fetchai/fetchai.py b/plugins/aea-ledger-fetchai/aea_ledger_fetchai/fetchai.py index 0dae730517..7faed8cb43 100644 --- a/plugins/aea-ledger-fetchai/aea_ledger_fetchai/fetchai.py +++ b/plugins/aea-ledger-fetchai/aea_ledger_fetchai/fetchai.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2022-2023 Valory AG +# Copyright 2022-2024 Valory AG # Copyright 2018-2019 Fetch.AI Limited # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -137,6 +137,34 @@ def send_signed_transactions( f"Sending a bundle of transactions is not supported for the {self.identifier} plugin" ) + def filter_event( + self, + event: Any, + match_single: Dict[str, Any], + match_any: Dict[str, Any], + to_block: int, + from_block: int, + batch_size: int, + max_retries: int, + reduce_factor: float, + timeout: int, + ) -> Optional[JSONLike]: + """Filter an event using batching to avoid RPC timeouts. + + :param event: the event to filter for. + :param match_single: the filter parameters with value checking against the event abi. It allows for defining a single match value. + :param match_any: the filter parameters with value checking against the event abi. It allows for defining multiple match values. + :param to_block: the block to which to filter. + :param from_block: the block from which to start filtering. + :param batch_size: the blocks' batch size of the filtering. + :param max_retries: the maximum number of retries. + :param reduce_factor: the percentage by which the batch size is reduced in case of a timeout. + :param timeout: a timeout in seconds to interrupt the operation in case the RPC request hangs. + """ + raise NotImplementedError( # pragma: nocover + f"Custom events' filtering is not supported for the {self.identifier} plugin" + ) + class FetchAIFaucetApi(CosmosFaucetApi): """Fetchai testnet faucet API.""" diff --git a/plugins/aea-ledger-solana/aea_ledger_solana/solana.py b/plugins/aea-ledger-solana/aea_ledger_solana/solana.py index 31bbb16bb8..20be5d6d59 100644 --- a/plugins/aea-ledger-solana/aea_ledger_solana/solana.py +++ b/plugins/aea-ledger-solana/aea_ledger_solana/solana.py @@ -860,3 +860,31 @@ def get_transaction_transfer_logs( # pylint: disable=too-many-arguments,too-man } return transfers # type: ignore # actually ok + + def filter_event( + self, + event: Any, + match_single: Dict[str, Any], + match_any: Dict[str, Any], + to_block: int, + from_block: int, + batch_size: int, + max_retries: int, + reduce_factor: float, + timeout: int, + ) -> Optional[JSONLike]: + """Filter an event using batching to avoid RPC timeouts. + + :param event: the event to filter for. + :param match_single: the filter parameters with value checking against the event abi. It allows for defining a single match value. + :param match_any: the filter parameters with value checking against the event abi. It allows for defining multiple match values. + :param to_block: the block to which to filter. + :param from_block: the block from which to start filtering. + :param batch_size: the blocks' batch size of the filtering. + :param max_retries: the maximum number of retries. + :param reduce_factor: the percentage by which the batch size is reduced in case of a timeout. + :param timeout: a timeout in seconds to interrupt the operation in case the RPC request hangs. + """ + raise NotImplementedError( # pragma: nocover + f"Custom events' filtering is not supported for the {self.identifier} plugin" + ) diff --git a/scripts/whitelist.py b/scripts/whitelist.py index fc8968b019..8c50aecddf 100644 --- a/scripts/whitelist.py +++ b/scripts/whitelist.py @@ -343,3 +343,11 @@ to_pipfile_string # unused method (aea/configurations/data_types.py:973) custom # unused function (aea/cli/scaffold.py:157) custom_loader # unused property (aea/cli/utils/context.py:158) +filter_event # unused method (aea/crypto/base.py:535) +match_single # unused variable (aea/crypto/base.py:539) +match_any # unused variable (aea/crypto/base.py:540) +to_block # unused variable (aea/crypto/base.py:541) +from_block # unused variable (aea/crypto/base.py:542) +batch_size # unused variable (aea/crypto/base.py:543) +max_retries # unused variable (aea/crypto/base.py:544) +reduce_factor # unused variable (aea/crypto/base.py:545)