From 40e73ec69e3567a077bc8bdbcc2f57bf02714182 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:58:26 -0400 Subject: [PATCH] feat: USE_FULL_REQUEST env (#98) * feat: env to init controller with full request DANKMIDS_USE_FULL_REQUEST * feat: move env to ENVS file --- dank_mids/ENVIRONMENT_VARIABLES.py | 4 ++++ dank_mids/controller.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dank_mids/ENVIRONMENT_VARIABLES.py b/dank_mids/ENVIRONMENT_VARIABLES.py index 9f4e50e9..4869827a 100644 --- a/dank_mids/ENVIRONMENT_VARIABLES.py +++ b/dank_mids/ENVIRONMENT_VARIABLES.py @@ -51,6 +51,10 @@ BROWNIE_DECODER_PROCESSES = _envs.create_env("BROWNIE_DECODER_PROCESSES", AsyncProcessPoolExecutor, default=0 if OPERATION_MODE.infura else 1, string_converter=int, verbose=not OPERATION_MODE.infura) MULTICALL_DECODER_PROCESSES = _envs.create_env("MULTICALL_DECODER_PROCESSES", AsyncProcessPoolExecutor, default=0 if OPERATION_MODE.infura else 1, string_converter=int, verbose=not OPERATION_MODE.infura) +# We use a modified version of the request spec that doesn't contain unnecessary fields, and switch to the full spec if necessary for your node. +# Set this env var to any value to force the full request spec always +USE_FULL_REQUEST = _envs.create_env("USE_FULL_REQUEST", bool, default=False, verbose=False) + # NOTE: EXPORT_STATS is not implemented # TODO: implement this EXPORT_STATS = _envs.create_env("EXPORT_STATS", bool, default=False, verbose=False) diff --git a/dank_mids/controller.py b/dank_mids/controller.py index 204142de..bc236b93 100644 --- a/dank_mids/controller.py +++ b/dank_mids/controller.py @@ -19,11 +19,11 @@ from dank_mids._demo_mode import demo_logger from dank_mids._exceptions import DankMidsInternalError from dank_mids.batch import DankBatch -from typing import ClassVar from dank_mids.helpers import decode, session from dank_mids.requests import JSONRPCBatch, Multicall, RPCRequest, eth_call from dank_mids.semaphores import MethodSemaphores -from dank_mids.types import BlockId, ChainId, PartialRequest, RawResponse +from dank_mids.types import (BlockId, ChainId, PartialRequest, RawResponse, + Request) from dank_mids.uid import UIDGenerator, _AlertingRLock try: @@ -54,7 +54,7 @@ def __init__(self, w3: Web3) -> None: self.chain_id = self.sync_w3.eth.chain_id # NOTE: We need this mutable for node types that require the full jsonrpc spec - self.request_type = PartialRequest + self.request_type = Request if ENVS.USE_FULL_REQUEST else PartialRequest self._time_of_request_type_change = 0 self.state_override_not_supported: bool = ENVS.GANACHE_FORK or self.chain_id == 100 # Gnosis Chain does not support state override.