From 7cfb6ff3188af64a0df6545447598feeb0a536bd Mon Sep 17 00:00:00 2001 From: Karl Bartel Date: Thu, 11 Mar 2021 15:07:44 +0100 Subject: [PATCH] Add unstable deployment on goerli This allows us to run a second set of services without sharing the same service registry. Closes https://github.com/raiden-network/raiden-contracts/issues/1438 --- raiden_contracts/constants.py | 1 + raiden_contracts/contract_manager.py | 35 ++++++++++-- .../data/deployment_goerli_unstable.json | 41 ++++++++++++++ .../deployment_services_goerli_unstable.json | 55 +++++++++++++++++++ 4 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 raiden_contracts/data/deployment_goerli_unstable.json create mode 100644 raiden_contracts/data/deployment_services_goerli_unstable.json diff --git a/raiden_contracts/constants.py b/raiden_contracts/constants.py index 963336f48..0ad8192de 100644 --- a/raiden_contracts/constants.py +++ b/raiden_contracts/constants.py @@ -142,6 +142,7 @@ class DeploymentModule(Enum): START_QUERY_BLOCK_KEY = "DefaultStartBlock" ID_TO_CHAINNAME: Dict[ChainID, str] = { + ChainID(-5): "goerli_unstable", ChainID(1): "mainnet", ChainID(3): "ropsten", ChainID(4): "rinkeby", diff --git a/raiden_contracts/contract_manager.py b/raiden_contracts/contract_manager.py index 8843d1b1b..e5e2e2481 100644 --- a/raiden_contracts/contract_manager.py +++ b/raiden_contracts/contract_manager.py @@ -1,4 +1,5 @@ """ContractManager knows binaries and ABI of contracts.""" +import enum import json from copy import deepcopy from json import JSONDecodeError @@ -146,13 +147,25 @@ def gas_measurements(version: Optional[str] = None) -> Dict[str, int]: return json.load(gas_file) +class ContractDevEnvironment(enum.Enum): + DEMO = "demo" + UNSTABLE = "unstable" + + def contracts_deployed_path( - chain_id: ChainID, version: Optional[str] = None, services: bool = False + chain_id: ChainID, + version: Optional[str] = None, + services: bool = False, + development_environment: ContractDevEnvironment = ContractDevEnvironment.DEMO, ) -> Path: """Returns the path of the deplolyment data JSON file.""" data_path = contracts_data_path(version) chain_name = ID_TO_CHAINNAME[chain_id] if chain_id in ID_TO_CHAINNAME else "private_net" + if development_environment == ContractDevEnvironment.UNSTABLE: + assert chain_name == "goerli", "Unstable contracts only available on goerli" + chain_name += "_unstable" + return data_path.joinpath(f'deployment_{"services_" if services else ""}{chain_name}.json') @@ -193,6 +206,7 @@ def get_contracts_deployment_info( chain_id: ChainID, version: Optional[str] = None, module: DeploymentModule = DeploymentModule.ALL, + development_environment: ContractDevEnvironment = ContractDevEnvironment.DEMO, ) -> Optional[DeployedContracts]: """Reads the deployment data. Returns None if the file is not found. @@ -209,7 +223,14 @@ def module_chosen(to_be_added: DeploymentModule) -> bool: files: List[Path] = [] if module_chosen(DeploymentModule.RAIDEN): - files.append(contracts_deployed_path(chain_id=chain_id, version=version, services=False)) + files.append( + contracts_deployed_path( + chain_id=chain_id, + version=version, + services=False, + development_environment=development_environment, + ) + ) if module == DeploymentModule.SERVICES and not contracts_version_provides_services(version): raise ValueError( @@ -218,8 +239,14 @@ def module_chosen(to_be_added: DeploymentModule) -> bool: ) if module_chosen(DeploymentModule.SERVICES) and contracts_version_provides_services(version): - files.append(contracts_deployed_path(chain_id=chain_id, version=version, services=True)) - + files.append( + contracts_deployed_path( + chain_id=chain_id, + version=version, + services=True, + development_environment=development_environment, + ) + ) deployment_data: Optional[DeployedContracts] = {} for f in files: diff --git a/raiden_contracts/data/deployment_goerli_unstable.json b/raiden_contracts/data/deployment_goerli_unstable.json new file mode 100644 index 000000000..360deef41 --- /dev/null +++ b/raiden_contracts/data/deployment_goerli_unstable.json @@ -0,0 +1,41 @@ +{ + "contracts_version": null, + "chain_id": 5, + "contracts": { + "SecretRegistry": { + "address": "0xC7657aB35Dc19dA658ab160F0913737f650d0642", + "transaction_hash": "0xe5ae2292f4f0d395ce1b35ef589bdf620bdd2d0cbfe9036265459da9f04f8e2c", + "block_number": 4422370, + "gas_cost": 247286, + "constructor_arguments": [] + }, + "TokenNetworkRegistry": { + "address": "0xE7871B43Dfe09EaeC25DA8961484bBcA4C133987", + "transaction_hash": "0x64e896cc8359817c73ad8f4d4de312307ef5d9ac7151cede184978360e61110c", + "block_number": 4422372, + "gas_cost": 4001594, + "constructor_arguments": [ + "0xC7657aB35Dc19dA658ab160F0913737f650d0642", + 5, + 20, + 555428, + 115792089237316195423570985008687907853269984665640564039457584007913129639935 + ] + } + }, + "token_networks": [ + { + "token_network_address": "0xfe3704dBFeca9A970E634f4b6D383f78AE979417", + "constructor_arguments": { + "_token_address": "0xC563388e2e2fdD422166eD5E76971D11eD37A466", + "_secret_registry": "0xC7657aB35Dc19dA658ab160F0913737f650d0642", + "_chain_id": 5, + "_settlement_timeout_min": 20, + "_settlement_timeout_max": 555428, + "_deprecation_executor": "0x062C12c01D0f17fC9eAa33940D994594d91a0182", + "_channel_participant_deposit_limit": 115792089237316195423570985008687907853269984665640564039457584007913129639935, + "_token_network_deposit_limit": 115792089237316195423570985008687907853269984665640564039457584007913129639935 + } + } + ] +} \ No newline at end of file diff --git a/raiden_contracts/data/deployment_services_goerli_unstable.json b/raiden_contracts/data/deployment_services_goerli_unstable.json new file mode 100644 index 000000000..54a238305 --- /dev/null +++ b/raiden_contracts/data/deployment_services_goerli_unstable.json @@ -0,0 +1,55 @@ +{ + "contracts_version": null, + "chain_id": 5, + "contracts": { + "ServiceRegistry": { + "address": "0x273bb54f21E23CeA5312bE2623ED97C25CBd6F0D", + "transaction_hash": "0xb55df847157286ac359952aa9bca2082c62c000bfd299a98ff95fd54c04930d4", + "block_number": 4422373, + "gas_cost": 1999628, + "constructor_arguments": [ + "0x5Fc523e13fBAc2140F056AD7A96De2cC0C4Cc63A", + "0x062C12c01D0f17fC9eAa33940D994594d91a0182", + 2000000000000000000000, + 6, + 5, + 17280000, + 1000, + 15552000 + ] + }, + "UserDeposit": { + "address": "0xD145252daB9323F9Acb70295d6a0589c611F225d", + "transaction_hash": "0x22526107c5e8174e1fe8a3da3b42499a14fc4088b8b236d85ff057b39a32e1e0", + "block_number": 4422374, + "gas_cost": 1530470, + "constructor_arguments": [ + "0x5Fc523e13fBAc2140F056AD7A96De2cC0C4Cc63A", + 115792089237316195423570985008687907853269984665640564039457584007913129639935 + ] + }, + "MonitoringService": { + "address": "0x1eF1F851689b6494f4eE6563c1979B5b018be51d", + "transaction_hash": "0x1894e9b205f09d8cbfc570b7b99f3915133c21157299c95e3b2cdbae01713c8b", + "block_number": 4422375, + "gas_cost": 1949901, + "constructor_arguments": [ + "0x5Fc523e13fBAc2140F056AD7A96De2cC0C4Cc63A", + "0x273bb54f21E23CeA5312bE2623ED97C25CBd6F0D", + "0xD145252daB9323F9Acb70295d6a0589c611F225d", + "0xE7871B43Dfe09EaeC25DA8961484bBcA4C133987" + ] + }, + "OneToN": { + "address": "0x8483c719F8Cd8ed8c8855Be3B2779AF8ef914D47", + "transaction_hash": "0x666b9d83f683062949520516617db045a565085f7f076effda62d31fea927f4d", + "block_number": 4422376, + "gas_cost": 1097797, + "constructor_arguments": [ + "0xD145252daB9323F9Acb70295d6a0589c611F225d", + 5, + "0x273bb54f21E23CeA5312bE2623ED97C25CBd6F0D" + ] + } + } +} \ No newline at end of file