Skip to content

Commit

Permalink
fix: allow easierly setting local gas lmt (#1878)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jan 23, 2024
1 parent e1c0863 commit 7959bb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/ape_ethereum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ class ForkedNetworkConfig(NetworkConfig):
def create_local_network_config(
default_provider: Optional[str] = None, use_fork: bool = False, **kwargs
):
if "gas_limit" not in kwargs:
kwargs["gas_limit"] = "max"

return create_network_config(
base_fee_multiplier=1.0,
default_provider=default_provider,
gas_limit="max",
required_confirmations=0,
transaction_acceptance_timeout=DEFAULT_LOCAL_TRANSACTION_ACCEPTANCE_TIMEOUT,
cls=ForkedNetworkConfig if use_fork else NetworkConfig,
Expand All @@ -167,6 +169,7 @@ class BaseEthereumConfig(PluginConfig):
"""

DEFAULT_TRANSACTION_TYPE: ClassVar[int] = TransactionType.DYNAMIC.value
DEFAULT_LOCAL_GAS_LIMIT: ClassVar[GasLimit] = "max"
NETWORKS: ClassVar[Dict[str, Tuple[int, int]]] = NETWORKS

default_network: str = LOCAL_NETWORK_NAME
Expand All @@ -189,7 +192,9 @@ def load_network_configs(cls, values):
if net_name.endswith("_fork"):
key = net_name.replace("_fork", "")
default_fork_model = create_local_network_config(
use_fork=True, default_transaction_type=cls.DEFAULT_TRANSACTION_TYPE
use_fork=True,
default_transaction_type=cls.DEFAULT_TRANSACTION_TYPE,
gas_limit=cls.DEFAULT_LOCAL_GAS_LIMIT,
).model_dump(mode="json", by_alias=True)
data = merge_configs(default_fork_model, obj)
cfg_forks[key] = ForkedNetworkConfig.model_validate(data)
Expand All @@ -209,7 +214,9 @@ def load_network_configs(cls, values):
@cached_property
def local(self) -> NetworkConfig:
return create_local_network_config(
default_provider="test", default_transaction_type=self.DEFAULT_TRANSACTION_TYPE
default_provider="test",
default_transaction_type=self.DEFAULT_TRANSACTION_TYPE,
gas_limit=self.DEFAULT_LOCAL_GAS_LIMIT,
)

def __getattr__(self, key: str) -> Any:
Expand Down Expand Up @@ -254,7 +261,9 @@ def _get_forked_config(self, name: str) -> Optional[ForkedNetworkConfig]:
if live_cfg := self.get(live_key):
if isinstance(live_cfg, NetworkConfig):
fork_cfg = create_local_network_config(
use_fork=True, default_transaction_type=self.DEFAULT_TRANSACTION_TYPE
use_fork=True,
default_transaction_type=self.DEFAULT_TRANSACTION_TYPE,
gas_limit=self.DEFAULT_LOCAL_GAS_LIMIT,
)
self._forked_configs[live_key] = fork_cfg
return fork_cfg
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_network_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_forked_network_with_config(temp_config, ethereum):
assert cfg.base_fee_multiplier == 1.0
assert cfg.transaction_acceptance_timeout == 20
assert cfg.max_receipt_retries == 20
assert cfg.gas_limit == "max"


def test_data_folder_custom_network(custom_network, ethereum, custom_network_name_0):
Expand Down

0 comments on commit 7959bb8

Please sign in to comment.