From 000434afd0a846b5fed7eabd98c9131240ccf314 Mon Sep 17 00:00:00 2001 From: badrogger Date: Thu, 30 May 2024 17:32:18 +0000 Subject: [PATCH] Set INF max_consensus_storage_bytes for archive node --- core/schains/config/schain_info.py | 8 ++++++- core/schains/config/skale_section.py | 4 +++- tests/schains/config/generator_test.py | 30 ++++++++++++++++++++++++++ tools/configs/schains.py | 2 ++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/core/schains/config/schain_info.py b/core/schains/config/schain_info.py index 738d3cc52..d6a5bab83 100644 --- a/core/schains/config/schain_info.py +++ b/core/schains/config/schain_info.py @@ -22,6 +22,8 @@ from core.schains.limits import get_schain_limit, get_schain_type from core.schains.types import MetricType +from tools.configs.schains import MAX_CONSENSUS_STORAGE_INF_VALUE + @dataclass class SChainInfo: @@ -69,10 +71,14 @@ def generate_schain_info( on_chain_etherbase: str, static_schain_info: dict, node_groups: dict, - nodes: dict + nodes: dict, + sync_node: bool, + archive: bool ) -> SChainInfo: schain_type = get_schain_type(schain['partOfNode']) volume_limits = get_schain_limit(schain_type, MetricType.volume_limits) + if sync_node and archive: + volume_limits['max_consensus_storage_bytes'] = MAX_CONSENSUS_STORAGE_INF_VALUE leveldb_limits = get_schain_limit(schain_type, MetricType.leveldb_limits) contract_storage_limit = leveldb_limits['contract_storage'] db_storage_limit = leveldb_limits['db_storage'] diff --git a/core/schains/config/skale_section.py b/core/schains/config/skale_section.py index 0b942d374..340644be1 100644 --- a/core/schains/config/skale_section.py +++ b/core/schains/config/skale_section.py @@ -92,7 +92,9 @@ def generate_skale_section( on_chain_etherbase=on_chain_etherbase, static_schain_info=static_schain_info, nodes=schain_nodes, - node_groups=node_groups + node_groups=node_groups, + sync_node=sync_node, + archive=archive ) return SkaleConfig( diff --git a/tests/schains/config/generator_test.py b/tests/schains/config/generator_test.py index a0c7042e4..570f766c4 100644 --- a/tests/schains/config/generator_test.py +++ b/tests/schains/config/generator_test.py @@ -480,6 +480,8 @@ def test_generate_sync_node_config_archive_catchup( assert not config['skaleConfig']['nodeInfo'].get('syncFromCatchup') assert not config['skaleConfig']['nodeInfo'].get('archiveMode') + assert config['skaleConfig']['sChain'].get('maxConsensusStorageBytes') < \ + 1000000000000000000 schain_config = generate_schain_config( schain=SCHAIN_WITHOUT_ORIGINATOR, @@ -502,6 +504,8 @@ def test_generate_sync_node_config_archive_catchup( assert config['skaleConfig']['nodeInfo'].get('syncFromCatchup') assert config['skaleConfig']['nodeInfo'].get('archiveMode') is False + assert config['skaleConfig']['sChain'].get('maxConsensusStorageBytes') < \ + 1000000000000000000 schain_config = generate_schain_config( schain=SCHAIN_WITHOUT_ORIGINATOR, @@ -524,6 +528,32 @@ def test_generate_sync_node_config_archive_catchup( assert config['skaleConfig']['nodeInfo'].get('syncFromCatchup') is None assert config['skaleConfig']['nodeInfo'].get('archiveMode') is None + assert config['skaleConfig']['sChain'].get('maxConsensusStorageBytes') < \ + 1000000000000000000 + + schain_config = generate_schain_config( + schain=SCHAIN_WITHOUT_ORIGINATOR, + node=TEST_NODE, + node_id=node_id, + ecdsa_key_name=ecdsa_key_name, + rotation_id=rotation_id, + schain_nodes_with_schains=get_schain_node_with_schains('test_schain'), + node_groups=node_groups, + generation=generation, + is_owner_contract=False, + skale_manager_opts=skale_manager_opts, + common_bls_public_keys=COMMON_BLS_PUBLIC_KEY, + schain_base_port=10000, + sync_node=True, + archive=True, + catchup=True + ) + config = schain_config.to_dict() + + assert config['skaleConfig']['nodeInfo'].get('syncFromCatchup') + assert config['skaleConfig']['nodeInfo'].get('archiveMode') + assert config['skaleConfig']['sChain'].get('maxConsensusStorageBytes') == \ + 1000000000000000000 def test_generate_sync_node_config_static_accounts( diff --git a/tools/configs/schains.py b/tools/configs/schains.py index c12967348..566709ca8 100644 --- a/tools/configs/schains.py +++ b/tools/configs/schains.py @@ -51,3 +51,5 @@ DEFAULT_RPC_CHECK_TIMEOUT = 30 RPC_CHECK_TIMEOUT_STEP = 10 + +MAX_CONSENSUS_STORAGE_INF_VALUE = 1000000000000000000