Skip to content

Commit

Permalink
feat: USE_FULL_REQUEST env (#98)
Browse files Browse the repository at this point in the history
* feat: env to init controller with full request

DANKMIDS_USE_FULL_REQUEST

* feat: move env to ENVS file
  • Loading branch information
BobTheBuidler authored Oct 11, 2023
1 parent d59fae4 commit 40e73ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions dank_mids/ENVIRONMENT_VARIABLES.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions dank_mids/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 40e73ec

Please sign in to comment.