Skip to content

Commit

Permalink
Merge pull request #1053 from skalenetwork/beta-sync-node
Browse files Browse the repository at this point in the history
Sync node stable (hotfix for 2.3 release)
  • Loading branch information
badrogger authored Feb 29, 2024
2 parents 06d542b + 44229cc commit 10c5446
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 16 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]
env:
ETH_PRIVATE_KEY: ${{ secrets.ETH_PRIVATE_KEY }}
SCHAIN_TYPE: ${{ secrets.SCHAIN_TYPE }}
MANAGER_TAG: "1.9.3-beta.0"
MANAGER_TAG: "1.10.0-beta.0"
IMA_TAG: "1.3.4-beta.5"
SGX_WALLET_TAG: "1.83.0-beta.5"
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -28,12 +28,26 @@ jobs:
run: bash ./scripts/install_python_dependencies.sh
- name: Lint with flake8
run: flake8 .
- name: Launch anvil node
run: |
docker run -d --network host --name anvil ghcr.io/foundry-rs/foundry anvil && sleep 5 && docker logs anvil --tail 1000
- name: Deploy manager & ima contracts
run: |
bash ./helper-scripts/deploy_test_ima.sh
docker rmi -f skalenetwork/skale-manager:${{ env.MANAGER_TAG }}
- name: Show stats before tests
if: always()
run: |
sudo lsblk -f
sudo free -h
- name: Run core tests
run: |
bash ./scripts/run_core_tests.sh
- name: Show stats after tests
if: always()
run: |
sudo lsblk -f
sudo free -h
- name: Run codecov
run: |
codecov -t $CODECOV_TOKEN
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "helper-scripts"]
path = helper-scripts
url = https://github.com/skalenetwork/helper-scripts.git
branch = develop
branch = fix-for-latest-sm
20 changes: 17 additions & 3 deletions core/schains/config/node_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ def generate_current_node_info(
node['port']
)

wallets = {} if sync_node else generate_wallets_config(schain['name'], rotation_id)
wallets = generate_wallets_config(
schain['name'],
rotation_id,
schain_nodes_number=len(schains_on_node),
sync_node=sync_node
)

if ecdsa_key_name is None:
logger.warning(f'Generating CurrentNodeInfo for {schain["name"]}, ecdsa_key_name is None')
Expand All @@ -105,15 +110,24 @@ def generate_current_node_info(
)


def generate_wallets_config(schain_name: str, rotation_id: int) -> dict:
def generate_wallets_config(
schain_name: str,
rotation_id: int,
schain_nodes_number: int,
sync_node: bool = False
) -> dict:
if sync_node:
return {
'ima': {'n': schain_nodes_number}
}
secret_key_share_filepath = get_secret_key_share_filepath(schain_name, rotation_id)
secret_key_share_config = read_json(secret_key_share_filepath)

wallets = {
'ima': {
'keyShareName': secret_key_share_config['key_share_name'],
't': secret_key_share_config['t'],
'n': secret_key_share_config['n'],
'n': schain_nodes_number,
'certFile': SGX_SSL_CERT_FILEPATH,
'keyFile': SGX_SSL_KEY_FILEPATH
}
Expand Down
2 changes: 1 addition & 1 deletion helper-scripts
2 changes: 2 additions & 0 deletions tests/dkg_test/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def schain(self, schain_creation_data, skale, nodes):
remove_schain(skale, schain_name)
cleanup_schain_config(schain_name)

@pytest.mark.skip('Not used in sync node')
def test_dkg_procedure(
self,
skale,
Expand Down Expand Up @@ -290,6 +291,7 @@ def no_ids_for_schain_skale(self, skale):
finally:
skale.schains_internal.get_node_ids_for_schain = get_node_ids_f

@pytest.mark.skip('Not used in sync node')
def test_failed_get_dkg_client(self, no_ids_for_schain_skale):
skale = no_ids_for_schain_skale
with pytest.raises(DkgError):
Expand Down
1 change: 1 addition & 0 deletions tests/node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def test_create_insufficient_funds(unregistered_node):
assert res['errors'] == ['Insufficient funds, re-check your wallet']


@pytest.mark.skip('No need for sync node')
def test_register_info(unregistered_node):
unregistered_node.config.id = None
ip, public_ip, port, name = generate_random_node_data()
Expand Down
25 changes: 15 additions & 10 deletions tests/schains/config/node_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@

def test_generate_wallets_config():
with mock.patch('core.schains.config.node_info.read_json', return_value=SECRET_KEY_MOCK):
wallets = generate_wallets_config('test_schain', 0)
wallets = generate_wallets_config('test_schain', 0, 4)

assert wallets['ima']['keyShareName'] == SECRET_KEY_MOCK['key_share_name']
assert wallets['ima']['certFile'] == SGX_SSL_CERT_FILEPATH
assert wallets['ima']['keyFile'] == SGX_SSL_KEY_FILEPATH
assert wallets['ima']['commonBLSPublicKey0'] == '1'
assert wallets['ima']['commonBLSPublicKey1'] == '1'
assert wallets['ima']['commonBLSPublicKey2'] == '1'
assert wallets['ima']['BLSPublicKey0'] == '1'
assert wallets['ima']['BLSPublicKey1'] == '1'
assert wallets['ima']['BLSPublicKey2'] == '1'
assert wallets['ima']['keyShareName'] == SECRET_KEY_MOCK['key_share_name']
assert wallets['ima']['certFile'] == SGX_SSL_CERT_FILEPATH
assert wallets['ima']['keyFile'] == SGX_SSL_KEY_FILEPATH
assert wallets['ima']['n'] == 4
assert wallets['ima']['commonBLSPublicKey0'] == '1'
assert wallets['ima']['commonBLSPublicKey1'] == '1'
assert wallets['ima']['commonBLSPublicKey2'] == '1'
assert wallets['ima']['BLSPublicKey0'] == '1'
assert wallets['ima']['BLSPublicKey1'] == '1'
assert wallets['ima']['BLSPublicKey2'] == '1'

with mock.patch('core.schains.config.node_info.read_json', return_value=SECRET_KEY_MOCK):
wallets = generate_wallets_config('test_schain', 0, 4, sync_node=True)
assert wallets['ima']['n'] == 4


def test_generate_current_node_info(
Expand Down

0 comments on commit 10c5446

Please sign in to comment.