-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #978 from skalenetwork/merge-beta-sync-node-to-stable
Merge beta sync node to stable
- 2.11.0-sync-node.5
- 2.11.0-sync-node.4
- 2.11.0-sync-node.3
- 2.10.0-develop.0
- 2.9.0-develop.1
- 2.9.0-develop.0
- 2.9.0-beta.1
- 2.9.0-beta.0
- 2.8.0
- 2.8.0-develop.16
- 2.8.0-develop.15
- 2.8.0-develop.14
- 2.8.0-develop.13
- 2.8.0-develop.12
- 2.8.0-develop.11
- 2.8.0-develop.10
- 2.8.0-develop.9
- 2.8.0-develop.8
- 2.8.0-develop.7
- 2.8.0-develop.6
- 2.8.0-develop.5
- 2.8.0-develop.4
- 2.8.0-develop.3
- 2.8.0-develop.2
- 2.8.0-develop.1
- 2.8.0-develop.0
- 2.8.0-beta.4
- 2.8.0-beta.3
- 2.8.0-beta.2
- 2.8.0-beta.1
- 2.8.0-beta.0
- 2.7.2
- 2.7.2-develop.0
- 2.7.2-beta.0
- 2.7.1
- 2.7.1-develop.1
- 2.7.1-develop.0
- 2.7.1-beta.0
- 2.7.0
- 2.7.0-develop.18
- 2.7.0-develop.17
- 2.7.0-develop.16
- 2.7.0-develop.15
- 2.7.0-develop.14
- 2.7.0-develop.13
- 2.7.0-develop.12
- 2.7.0-develop.11
- 2.7.0-develop.10
- 2.7.0-develop.9
- 2.7.0-develop.8
- 2.7.0-develop.7
- 2.7.0-develop.6
- 2.7.0-develop.5
- 2.7.0-develop.4
- 2.7.0-develop.3
- 2.7.0-develop.2
- 2.7.0-develop.1
- 2.7.0-develop.0
- 2.7.0-beta.4
- 2.7.0-beta.3
- 2.7.0-beta.2
- 2.7.0-beta.1
- 2.7.0-beta.0
Showing
9 changed files
with
176 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of SKALE Admin | ||
# | ||
# Copyright (C) 2023-Present SKALE Labs | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import os | ||
|
||
from tools.helper import read_json | ||
from tools.configs import STATIC_ACCOUNTS_FOLDER, ENV_TYPE | ||
|
||
|
||
def static_accounts(schain_name: str) -> dict: | ||
return read_json(static_accounts_filepath(schain_name)) | ||
|
||
|
||
def is_static_accounts(schain_name: str) -> bool: | ||
return os.path.isfile(static_accounts_filepath(schain_name)) | ||
|
||
|
||
def static_accounts_filepath(schain_name: str) -> str: | ||
static_accounts_env_path = os.path.join(STATIC_ACCOUNTS_FOLDER, ENV_TYPE) | ||
if not os.path.isdir(static_accounts_env_path): | ||
return '' | ||
return os.path.join(static_accounts_env_path, f'schain-{schain_name}.json') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ mock==4.0.2 | |
blinker==1.4 | ||
|
||
pytest-cov==2.9.0 | ||
codecov==2.1.9 | ||
codecov==2.1.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from core.schains.config.static_accounts import is_static_accounts, static_accounts | ||
|
||
SCHAIN_NAME = 'test' | ||
|
||
|
||
def test_is_static_accounts(): | ||
assert is_static_accounts(SCHAIN_NAME) | ||
assert not is_static_accounts('qwerty') | ||
|
||
|
||
def test_static_accounts(): | ||
accounts = static_accounts(SCHAIN_NAME) | ||
assert isinstance(accounts, dict) | ||
assert accounts.get('accounts', None) |
7 changes: 7 additions & 0 deletions
7
tests/skale-data/config/schain_accounts/devnet/schain-test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"accounts": { | ||
"0x9d8C194E07c628C15C82f06a53cCCf3c7b68810D": { | ||
"balance": "1000000000000000000000000000000" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import json | ||
import pytest | ||
from skale.schain_config.rotation_history import get_previous_schain_groups | ||
|
||
from core.schains.config.predeployed import generate_predeployed_accounts | ||
from core.schains.config.precompiled import generate_precompiled_accounts | ||
|
||
from core.schains.limits import get_schain_type | ||
from core.schains.config.generator import ( | ||
get_on_chain_owner, get_schain_originator, SChainBaseConfig) | ||
|
||
from tools.helper import is_address_contract | ||
from tools.configs.schains import BASE_SCHAIN_CONFIG_FILEPATH | ||
|
||
|
||
CHAINS = [] | ||
|
||
|
||
@pytest.mark.skip(reason="test only used to generate static accounts for a sync node") | ||
def test_generate_config(skale): | ||
for schain_name in CHAINS: | ||
|
||
schain = skale.schains.get_by_name(schain_name) | ||
schain_type = get_schain_type(schain['partOfNode']) | ||
|
||
node_groups = get_previous_schain_groups(skale, schain_name) | ||
original_group = node_groups[0]['nodes'] | ||
|
||
schain_nodes_with_schains = [] | ||
for key, value in original_group.items(): | ||
schain_nodes_with_schains.append({ | ||
'id': int(key), | ||
'publicKey': value[2] | ||
}) | ||
|
||
is_owner_contract = is_address_contract(skale.web3, schain['mainnetOwner']) | ||
on_chain_owner = get_on_chain_owner(schain, schain['generation'], is_owner_contract) | ||
|
||
mainnet_owner = schain['mainnetOwner'] | ||
|
||
originator_address = get_schain_originator(schain) | ||
|
||
precompiled_accounts = generate_precompiled_accounts( | ||
on_chain_owner=on_chain_owner | ||
) | ||
|
||
base_config = SChainBaseConfig(BASE_SCHAIN_CONFIG_FILEPATH) | ||
|
||
predeployed_accounts = generate_predeployed_accounts( | ||
schain_name=schain['name'], | ||
schain_type=schain_type, | ||
schain_nodes=schain_nodes_with_schains, | ||
on_chain_owner=on_chain_owner, | ||
mainnet_owner=mainnet_owner, | ||
originator_address=originator_address, | ||
generation=schain['generation'] | ||
) | ||
|
||
accounts = { | ||
**base_config.config['accounts'], | ||
**predeployed_accounts, | ||
**precompiled_accounts, | ||
} | ||
with open(f'accounts/schain-{schain_name}.json', 'w') as outfile: | ||
json.dump({'accounts': accounts}, outfile, indent=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters