Skip to content

Commit

Permalink
Deal with problematic RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Jan 8, 2025
1 parent 633d5b0 commit 9435440
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions eth_defi/lagoon/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""
import logging
import os
import time
from dataclasses import dataclass, asdict
from io import StringIO
from pathlib import Path
Expand All @@ -30,6 +31,7 @@
from eth_defi.lagoon.beacon_proxy import deploy_beacon_proxy
from eth_defi.lagoon.vault import LagoonVault
from eth_defi.middleware import construct_sign_and_send_raw_middleware_anvil
from eth_defi.provider.anvil import is_anvil
from eth_defi.safe.deployment import deploy_safe, add_new_safe_owners
from eth_defi.token import get_wrapped_native_token_address, fetch_erc20_details
from eth_defi.trace import assert_transaction_success_with_explanation
Expand Down Expand Up @@ -414,6 +416,7 @@ def deploy_automated_lagoon_vault(
any_asset: bool = False,
etherscan_api_key: str = None,
use_forge=False,
between_contracts_delay_seconds=10.0,
) -> LagoonAutomatedDeployment:
"""Deploy a full Lagoon setup with a guard.
Expand Down Expand Up @@ -446,6 +449,10 @@ def deploy_automated_lagoon_vault(

parameters.safe = safe.address

if not is_anvil(web3):
logger.info("Between contracts deployment delay: Sleeping %s for new nonce to propagade", between_contracts_delay_seconds)
time.sleep(between_contracts_delay_seconds)

vault_contract = deploy_lagoon(
web3=web3,
deployer=deployer,
Expand All @@ -457,6 +464,10 @@ def deploy_automated_lagoon_vault(
use_forge=use_forge,
)

if not is_anvil(web3):
logger.info("Between contracts deployment delay: Sleeping %s for new nonce to propagade", between_contracts_delay_seconds)
time.sleep(between_contracts_delay_seconds)

module = deploy_safe_trading_strategy_module(
web3=web3,
deployer=deployer,
Expand Down
6 changes: 6 additions & 0 deletions eth_defi/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ def is_retryable_http_exception(
if message in retryable_rpc_error_messages:
return True

for string_check in retryable_rpc_error_messages:
if string_check in message:
# Some RPCs add their own crap to the error messages, so exact error
# message matching does not seem to work
return True

return False

if isinstance(exc, ProbablyNodeHasNoBlock):
Expand Down
2 changes: 2 additions & 0 deletions eth_defi/safe/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def deploy_safe(
# Check that we can read back Safe data
retrieved_owners = safe.retrieve_owners()
assert retrieved_owners == owners

logger.info("Safe deployed at %s", safe.address)
return safe


Expand Down

0 comments on commit 9435440

Please sign in to comment.