diff --git a/Makefile b/Makefile index b784c5eb..936ce744 100644 --- a/Makefile +++ b/Makefile @@ -100,3 +100,4 @@ dot-env: grep -q -o MONGO_INITDB_ROOT_PASSWORD .env || echo "MONGO_INITDB_ROOT_PASSWORD=$$(xxd -l 16 -p /dev/urandom)" >> .env grep -q -o TNB_SECRET_KEY .env || echo "TNB_SECRET_KEY=$$(xxd -c 48 -l 48 -p /dev/urandom)" >> .env grep -q -o TNB_NODE_SIGNING_KEY .env || echo "TNB_NODE_SIGNING_KEY=$$(poetry run python -m node.manage generate_signing_key)" >> .env + grep -q -o TNB_NODE_SCHEDULE_CAPACITY .env || echo "TNB_NODE_SCHEDULE_CAPACITY=20" >> .env diff --git a/docker-compose.yml b/docker-compose.yml index ef27e620..5d116f12 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,7 +47,7 @@ services: TNB_DATABASES: '{"default":{"CLIENT":{"host":"node-mongo","password":"${MONGO_INITDB_ROOT_PASSWORD}"}}}' TNB_CELERY_BROKER_URL: 'amqp://guest:guest@celery-broker:5672//' env_file: .env - command: poetry run celery -A node.config.celery worker --loglevel=INFO + command: poetry run celery -A node.config.celery worker --loglevel=INFO --concurrency=${TNB_NODE_SCHEDULE_CAPACITY} depends_on: - node-mongo - celery-broker diff --git a/node/blockchain/inner_models/signed_change_request_message/pv_schedule_update.py b/node/blockchain/inner_models/signed_change_request_message/pv_schedule_update.py index c7fc06a4..c8632aa6 100644 --- a/node/blockchain/inner_models/signed_change_request_message/pv_schedule_update.py +++ b/node/blockchain/inner_models/signed_change_request_message/pv_schedule_update.py @@ -22,7 +22,7 @@ def should_not_be_empty(cls, schedule): @validator('schedule') def should_contain_not_more_elements(cls, schedule): - if len(schedule) > (schedule_capacity := settings.SCHEDULE_CAPACITY): + if len(schedule) > (schedule_capacity := settings.NODE_SCHEDULE_CAPACITY): raise ValidationError(f'Schedule should contain not more than {schedule_capacity} elements') return schedule diff --git a/node/blockchain/tests/test_models/test_signed_change_request_message/test_pv_schedule_update.py b/node/blockchain/tests/test_models/test_signed_change_request_message/test_pv_schedule_update.py index 9029c6a3..a6587ccd 100644 --- a/node/blockchain/tests/test_models/test_signed_change_request_message/test_pv_schedule_update.py +++ b/node/blockchain/tests/test_models/test_signed_change_request_message/test_pv_schedule_update.py @@ -38,10 +38,10 @@ def test_schedule_contain_at_least_one_element(): def test_schedule_capacity(): with pytest.raises( - ValidationError, match=f'Schedule should contain not more than {settings.SCHEDULE_CAPACITY} elements' + ValidationError, match=f'Schedule should contain not more than {settings.NODE_SCHEDULE_CAPACITY} elements' ): PVScheduleUpdateSignedChangeRequestMessage( - schedule={str(n): (str(n) * 64)[:64] for n in range(settings.SCHEDULE_CAPACITY + 1)}, + schedule={str(n): (str(n) * 64)[:64] for n in range(settings.NODE_SCHEDULE_CAPACITY + 1)}, account_lock='0' * 64, ) diff --git a/node/config/settings/__init__.py b/node/config/settings/__init__.py index 671a65ce..910e54d8 100644 --- a/node/config/settings/__init__.py +++ b/node/config/settings/__init__.py @@ -37,3 +37,4 @@ if not is_pytest_running(): assert SECRET_KEY is not NotImplemented # type: ignore # noqa: F821 assert NODE_SIGNING_KEY is not NotImplemented # type: ignore # noqa: F821 + assert NODE_SCHEDULE_CAPACITY is not NotImplemented # type: ignore # noqa: F821 diff --git a/node/config/settings/custom.py b/node/config/settings/custom.py index 7ba6ebef..6f253cae 100644 --- a/node/config/settings/custom.py +++ b/node/config/settings/custom.py @@ -11,7 +11,7 @@ NODE_LIST_JSON_PATH = None SYNC_BATCH_SIZE = 10 -SCHEDULE_CAPACITY = 20 +NODE_SCHEDULE_CAPACITY = NotImplemented SUPPRESS_WARNINGS_TB = True diff --git a/node/config/settings/templates/settings.dev.py b/node/config/settings/templates/settings.dev.py index b24b3e92..aa6ae085 100644 --- a/node/config/settings/templates/settings.dev.py +++ b/node/config/settings/templates/settings.dev.py @@ -17,3 +17,4 @@ DATABASES['default']['CLIENT']['connectTimeoutMS'] = 1000 NODE_SIGNING_KEY = 'a37e2836805975f334108b55523634c995bd2a4db610062f404510617e83126f' +NODE_SCHEDULE_CAPACITY = 20 diff --git a/node/core/tests/fixtures/misc.py b/node/core/tests/fixtures/misc.py index 16d02b60..617f1999 100644 --- a/node/core/tests/fixtures/misc.py +++ b/node/core/tests/fixtures/misc.py @@ -20,6 +20,7 @@ def test_settings(settings): NODE_SIGNING_KEY='a025da120a1c95b27f17bb9442af9c27d3a357733aa150b458f21682a2d539a9', CELERY_BROKER_URL='memory://', CELERY_TASK_ALWAYS_EAGER=True, + NODE_SCHEDULE_CAPACITY=20, ): # For some reason we need to import the app to make celery settings work from node.config.celery import app # noqa: F401 diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 13f8f842..aa7dad06 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -32,6 +32,7 @@ echo 'Creating/updating .env file...' test -f .env || touch .env grep -q -o MONGO_INITDB_ROOT_PASSWORD .env || echo "MONGO_INITDB_ROOT_PASSWORD=$(xxd -l 16 -p /dev/urandom)" >> .env grep -q -o TNB_SECRET_KEY .env || echo "TNB_SECRET_KEY=$(xxd -c 48 -l 48 -p /dev/urandom)" >> .env +grep -q -o TNB_NODE_SCHEDULE_CAPACITY .env || echo "TNB_NODE_SCHEDULE_CAPACITY=20" >> .env docker-compose pull