diff --git a/setup.py b/setup.py index fa46ba0d..8e61c244 100644 --- a/setup.py +++ b/setup.py @@ -57,10 +57,9 @@ url="https://github.com/SilverBackLtd/sdk", include_package_data=True, install_requires=[ - "eth-ape>=0.6.11,<1.0", + "eth-ape>=0.6.15,<1.0", "taskiq[metrics]>=0.6.0,<0.7.0", - # Can loosen constraint once https://github.com/pallets/click/issues/2558 resolved - "click==8.1.3", + "click", # Use same version as eth-ape ], entry_points={ "console_scripts": ["silverback=silverback._cli:cli"], diff --git a/silverback/application.py b/silverback/application.py index c8b82344..06fdeec0 100644 --- a/silverback/application.py +++ b/silverback/application.py @@ -1,6 +1,8 @@ import atexit +from datetime import timedelta from typing import Callable, Dict, Optional, Union +from ape.api.networks import LOCAL_NETWORK_NAME from ape.contracts import ContractEvent, ContractInstance from ape.logging import logger from ape.managers.chain import BlockContainer @@ -20,6 +22,13 @@ def __init__(self, settings: Optional[Settings] = None): if not settings: settings = Settings() + # Adjust defaults from connection + if settings.NEW_BLOCK_TIMEOUT is None and ( + self.chain_manager.provider.network.name.endswith("-fork") + or self.chain_manager.provider.network.name == LOCAL_NETWORK_NAME + ): + settings.NEW_BLOCK_TIMEOUT = int(timedelta(days=1).total_seconds()) + settings_str = "\n ".join(f'{key}="{val}"' for key, val in settings.dict().items() if val) logger.info(f"Loading Silverback App with settings:\n {settings_str}") @@ -39,7 +48,14 @@ def __init__(self, settings: Optional[Settings] = None): network_str = f'\n NETWORK="{provider.network.ecosystem.name}:{provider.network.name}"' signer_str = f"\n SIGNER={repr(self.signer)}" - logger.info(f"Loaded Silverback App:{network_str}{signer_str}") + start_block_str = f"\n START_BLOCK={self.start_block}" if self.start_block else "" + new_bock_timeout_str = ( + f"\n NEW_BLOCK_TIMEOUT={self.new_block_timeout}" if self.new_block_timeout else "" + ) + logger.info( + f"Loaded Silverback App:{network_str}" + f"{signer_str}{start_block_str}{new_bock_timeout_str}" + ) def on_startup(self) -> Callable: """