Skip to content

Commit

Permalink
Allow selection of unstable env/contracts
Browse files Browse the repository at this point in the history
Allow switching between the two contract deployments on goerli and
default to the old/demo contracts. See
raiden-network/light-client#2521 on why we
want to do this.

Closes #6862
  • Loading branch information
karlb committed Apr 23, 2021
1 parent 75e4371 commit 688d004
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
3 changes: 2 additions & 1 deletion raiden/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
TokenAddress,
TokenAmount,
)
from raiden_contracts.contract_manager import contracts_precompiled_path
from raiden_contracts.contract_manager import ContractDevEnvironment, contracts_precompiled_path

CACHE_TTL = 60
GAS_LIMIT = 10 * 10 ** 6
Expand Down Expand Up @@ -206,6 +206,7 @@ class RaidenConfig:
blockchain: BlockchainConfig = BlockchainConfig()
mediation_fees: MediationFeeConfig = MediationFeeConfig()
services: ServiceConfig = ServiceConfig()
development_environment: ContractDevEnvironment = ContractDevEnvironment.DEMO

transport_type: str = "matrix"
transport: MatrixTransportConfig = MatrixTransportConfig(
Expand Down
6 changes: 4 additions & 2 deletions raiden/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
UserDepositAddress,
)
from raiden_contracts.constants import CONTRACT_TOKEN_NETWORK_REGISTRY, ID_TO_CHAINNAME
from raiden_contracts.contract_manager import ContractManager
from raiden_contracts.contract_manager import ContractDevEnvironment, ContractManager

log = structlog.get_logger(__name__)

Expand Down Expand Up @@ -187,6 +187,7 @@ def setup_raiden_config(
matrix_server: str,
chain_id: ChainID,
environment_type: Environment,
development_environment: ContractDevEnvironment,
unrecoverable_error_should_crash: bool,
pathfinding_max_paths: int,
enable_monitoring: bool,
Expand Down Expand Up @@ -257,6 +258,7 @@ def setup_raiden_config(
config = RaidenConfig(
chain_id=chain_id,
environment_type=environment_type,
development_environment=development_environment,
reveal_timeout=default_reveal_timeout,
settle_timeout=default_settle_timeout,
console=console,
Expand Down Expand Up @@ -305,7 +307,7 @@ def run_raiden_service(

address, privatekey = get_account_and_private_key(account_manager, address, password_file)

contracts = load_deployed_contracts_data(config, chain_id)
contracts = load_deployed_contracts_data(config, chain_id, config.development_environment)

rpc_client = JSONRPCClient(
web3=web3,
Expand Down
10 changes: 10 additions & 0 deletions raiden/ui/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
from raiden.utils.system import get_system_spec
from raiden.utils.typing import MYPY_ANNOTATION, ChainID
from raiden_contracts.constants import ID_TO_CHAINNAME
from raiden_contracts.contract_manager import ContractDevEnvironment

log = structlog.get_logger(__name__)
ETH_RPC_CONFIG_OPTION = "--eth-rpc-endpoint"
Expand Down Expand Up @@ -235,6 +236,15 @@ def handle_version_option(ctx: Context, _param: Any, value: bool) -> None:
default=Environment.PRODUCTION.value,
show_default=True,
),
option(
"--development-environment",
help=(
"Choose which set of services and transport servers should be used. "
"Change this only when you are developing Raiden itself."
),
type=EnumChoiceType(ContractDevEnvironment),
default=ContractDevEnvironment.DEMO.value,
),
option(
"--accept-disclaimer",
help="Bypass the experimental software disclaimer prompt",
Expand Down
11 changes: 9 additions & 2 deletions raiden/ui/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ID_TO_CHAINNAME,
)
from raiden_contracts.contract_manager import (
ContractDevEnvironment,
contracts_precompiled_path,
get_contracts_deployment_info,
)
Expand Down Expand Up @@ -134,7 +135,11 @@ def __post_init__(self) -> None:
)


def load_deployed_contracts_data(config: RaidenConfig, chain_id: ChainID) -> Dict[str, Any]:
def load_deployed_contracts_data(
config: RaidenConfig,
chain_id: ChainID,
development_environment: ContractDevEnvironment = ContractDevEnvironment.DEMO,
) -> Dict[str, Any]:
"""Sets the contract deployment data depending on the network id and environment type
If an invalid combination of network id and environment type is provided, exits
Expand All @@ -149,7 +154,9 @@ def load_deployed_contracts_data(config: RaidenConfig, chain_id: ChainID) -> Dic

if chain_id in ID_TO_CHAINNAME and ID_TO_CHAINNAME[chain_id] != "smoketest":
deployment_data = get_contracts_deployment_info(
chain_id=chain_id, version=contracts_version
chain_id=chain_id,
version=contracts_version,
development_environment=development_environment,
)
if not deployment_data:
return deployed_contracts_data
Expand Down

0 comments on commit 688d004

Please sign in to comment.