Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Commit

Permalink
Add unstable deployment on goerli
Browse files Browse the repository at this point in the history
This allows us to run a second set of services without sharing the same
service registry.

Closes raiden-network#1438
  • Loading branch information
karlb committed Mar 11, 2021
1 parent e268bd7 commit 7cfb6ff
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 4 deletions.
1 change: 1 addition & 0 deletions raiden_contracts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
35 changes: 31 additions & 4 deletions raiden_contracts/contract_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ContractManager knows binaries and ABI of contracts."""
import enum
import json
from copy import deepcopy
from json import JSONDecodeError
Expand Down Expand Up @@ -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')


Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand All @@ -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:
Expand Down
41 changes: 41 additions & 0 deletions raiden_contracts/data/deployment_goerli_unstable.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
55 changes: 55 additions & 0 deletions raiden_contracts/data/deployment_services_goerli_unstable.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}

0 comments on commit 7cfb6ff

Please sign in to comment.