Skip to content

Commit

Permalink
Merge pull request #1078 from skalenetwork/no-consensus-db-limit
Browse files Browse the repository at this point in the history
Set max_consensus_storage_bytes to INF for archive node
  • Loading branch information
badrogger authored Jun 7, 2024
2 parents 6656d31 + 000434a commit 7297ffc
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/schains/config/schain_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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']
Expand Down
4 changes: 3 additions & 1 deletion core/schains/config/skale_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
30 changes: 30 additions & 0 deletions tests/schains/config/generator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions tools/configs/schains.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@

DEFAULT_RPC_CHECK_TIMEOUT = 30
RPC_CHECK_TIMEOUT_STEP = 10

MAX_CONSENSUS_STORAGE_INF_VALUE = 1000000000000000000

0 comments on commit 7297ffc

Please sign in to comment.