Skip to content

Commit ca74c8f

Browse files
Yoichi Hiraipirapira
authored andcommitted
Warn users on mainnet with --development
because --development crashes the node more often.
1 parent bcf950b commit ca74c8f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

raiden/ui/checks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ def check_ethereum_network_id(given_network_id: ChainID, web3: Web3) -> None:
152152
sys.exit(1)
153153

154154

155+
def check_raiden_environment(network_id: ChainID, environment_type: Environment) -> None:
156+
warn = ( # mainnet --development is only for tests
157+
network_id == 1 and environment_type == Environment.DEVELOPMENT
158+
)
159+
if warn:
160+
click.secho(
161+
f"The chosen network ({ID_TO_NETWORKNAME[network_id]}) is not a testnet, "
162+
f'but the "development" environment was selected.\n'
163+
f"This crashes the node often. Please start again with a safe environment setting "
164+
f"(--environment production).",
165+
fg="red",
166+
)
167+
168+
155169
def check_smart_contract_addresses(
156170
environment_type: Environment,
157171
node_network_id: ChainID,

raiden/ui/startup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
from raiden.network.proxies.token_network_registry import TokenNetworkRegistry
1414
from raiden.network.proxies.user_deposit import UserDeposit
1515
from raiden.settings import RAIDEN_CONTRACT_VERSION
16-
from raiden.ui.checks import check_pfs_configuration, check_smart_contract_addresses
16+
from raiden.ui.checks import (
17+
check_pfs_configuration,
18+
check_raiden_environment,
19+
check_smart_contract_addresses,
20+
)
1721
from raiden.utils.typing import Address, ChainID, TokenNetworkRegistryAddress
1822
from raiden_contracts.constants import (
1923
CONTRACT_SECRET_REGISTRY,
@@ -46,6 +50,10 @@ def setup_contracts_or_exit(config: Dict[str, Any], network_id: ChainID) -> Dict
4650
If an invalid combination of network id and environment type is provided, exits
4751
the program with an error
4852
"""
53+
environment_type = config["environment_type"]
54+
55+
check_raiden_environment(network_id, environment_type)
56+
4957
contracts: Dict[str, Any] = dict()
5058
contracts_version = RAIDEN_CONTRACT_VERSION
5159

0 commit comments

Comments
 (0)