From ce0ac954181439f9a50ae72b6d05e7d526aefeca Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Sat, 4 May 2024 15:23:07 -0400 Subject: [PATCH 1/4] feat: add `eager_caching: true` to default-config.yaml --- brownie/data/default-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/brownie/data/default-config.yaml b/brownie/data/default-config.yaml index a0c5ad16f..10d4fb7c4 100644 --- a/brownie/data/default-config.yaml +++ b/brownie/data/default-config.yaml @@ -71,3 +71,4 @@ hypothesis: autofetch_sources: false dependencies: null dev_deployment_artifacts: false +eager_caching: false From 71e6e2e0d8b878cf5761fdcd1e3c9b90ced90021 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Sat, 4 May 2024 15:26:34 -0400 Subject: [PATCH 2/4] fix: default --- brownie/data/default-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brownie/data/default-config.yaml b/brownie/data/default-config.yaml index 10d4fb7c4..4389f5c54 100644 --- a/brownie/data/default-config.yaml +++ b/brownie/data/default-config.yaml @@ -71,4 +71,4 @@ hypothesis: autofetch_sources: false dependencies: null dev_deployment_artifacts: false -eager_caching: false +eager_caching: true From e181b29a5e8ef52a5eda1aad95ee3b8ec9f59441 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Sat, 4 May 2024 15:30:35 -0400 Subject: [PATCH 3/4] feat: read `eager_caching` from brownie-config.yaml --- brownie/network/middlewares/caching.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/brownie/network/middlewares/caching.py b/brownie/network/middlewares/caching.py index c6cb19945..469904fa4 100644 --- a/brownie/network/middlewares/caching.py +++ b/brownie/network/middlewares/caching.py @@ -117,6 +117,9 @@ def start_block_filter_loop(self): @classmethod def get_layer(cls, w3: Web3, network_type: str) -> Optional[int]: + if CONFIG.settings['eager_caching'] is False: + # do not cache when user doesn't want it + return None if network_type != "live": # do not cache on development chains return None From 6f08cc4888df2d5d340012a60f72b075c68fc489 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Sat, 4 May 2024 15:47:23 -0400 Subject: [PATCH 4/4] chore: add docs --- docs/config.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/config.rst b/docs/config.rst index 946461ccd..70127df5a 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -390,3 +390,10 @@ Other Settings .. code-block:: yaml dotenv: .env + +.. py:attribute:: eager_caching + If set to ``false``, brownie will not start the background caching thread and will only call the RPC on an as-needed basis. + + This is useful for always-on services or while using pay-as-you-go private RPCs + + default value: ``true``