Skip to content

fix: broken ci test - #1339

Merged
cristiam86 merged 34 commits into
mainfrom
dxp-699-fix-broken-ci-test
Nov 20, 2025
Merged

cristiam86 merged 34 commits into
mainfrom
dxp-699-fix-broken-ci-test

Conversation

@kstroobants

@kstroobants kstroobants commented Oct 9, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #DXP-699

What

  • Added Redis-based event subscription system for validator changes in both RPC and consensus worker services
  • Implemented validator change event handlers that automatically reload validators when they are created, updated, or deleted
  • Enhanced LLM provider registry with IntegrityError handling for concurrent worker access
  • Added session.expire_all() calls to validators registry to ensure fresh database reads
  • Updated CI workflow to include consensus-worker service in build and deployment pipeline
  • Fixed environment variable configuration in CI tests (VITE_FINALITY_WINDOW, resource limits)

Why

  • To fix broken CI tests that were failing due to missing consensus-worker service in the deployment pipeline
  • To enable distributed consensus worker architecture where multiple workers can process transactions concurrently
  • To ensure validator changes are propagated across all running instances (RPC and workers) in real-time
  • To prevent race conditions and data inconsistencies when multiple workers access the same database resources
  • To improve system reliability and scalability by implementing proper event-driven architecture

Testing done

  • Updated CI workflow to build and deploy consensus-worker service alongside other backend services
  • Verified that validator change events are properly broadcast via Redis pub/sub
  • Confirmed that session expiration ensures fresh data reads from database
  • Validated that environment variable configuration works correctly in CI environment

Decisions made

Checks

  • I have tested this code
  • I have reviewed my own PR
  • I have created an issue for this PR
  • I have set a descriptive PR title compliant with conventional commits

Reviewing tips

User facing release notes

  • Improved System Reliability: Fixed CI test failures and improved distributed worker architecture
  • Enhanced Validator Management: Validator changes now automatically propagate to all running instances

Summary by CodeRabbit

  • New Features

    • Real-time validator management with automatic reloads and cross-service event propagation
    • Validator event subscription/publishing to keep services synchronized
  • Bug Fixes

    • Prevented concurrent seeding crashes for LLM providers
    • Ensured fresh validator reads to fix registry cache inconsistencies
    • Transaction insertion now returns a transaction hash after commit
    • Improved mock handling for provider responses to better mirror real results
  • Chores

    • CI updated to set service resource limits and start the consensus worker
  • Tests

    • Tests adapted to the new validator manager, provider/account flows, and schema changes (some fields now optional)

✏️ Tip: You can customize this high-level summary in your review settings.

@kstroobants kstroobants self-assigned this Oct 9, 2025
@coderabbitai

coderabbitai Bot commented Oct 9, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Introduce a shared validators.Manager across RPC and endpoints, add Redis-based validator lifecycle publishing on channel validator:events, subscribe workers and RPC lifespan to those events to restart validators, refactor validator initialization and registry usage, adjust DB handlers and tests, and update CI Docker environment and services.

Changes

Cohort / File(s) Summary
Validator Manager DI & endpoints
backend/protocol_rpc/endpoints.py, backend/protocol_rpc/rpc_methods.py, backend/protocol_rpc/app_lifespan.py, backend/protocol_rpc/validators_init.py
Replace direct ModifiableValidatorsRegistry usage with injected validators.Manager; add validators_manager parameters, forward it through RPC endpoints, initialize/restart validators via manager, and create validators using validators_manager.registry.
Redis event publishing (notifier)
backend/validators/__init__.py
Add async _notify_validator_change(event_type, data) to publish JSON events to validator:events (reads REDIS_URL) and invoke it after create/update/delete/delete_all registry mutations via interceptor.
Event subscription & worker handling
backend/protocol_rpc/message_handler/redis_worker_handler.py, backend/protocol_rpc/redis_subscriber.py, backend/consensus/worker_service.py
Add VALIDATOR_CHANNEL = "validator:events" and subscribe_to_validator_events(callback) with a background listener; subscribe to the channel in redis_subscriber; worker service subscribes and restarts validators via handler callbacks.
Validators registry DB reads
backend/database_handler/validators_registry.py
Call session.expire_all() at the start of count_validators, get_all_validators, and get_validator to ensure fresh ORM state before reads.
LLM providers DB conflict handling
backend/database_handler/llm_providers.py
Wrap commit() in reset_defaults() and update_defaults() with try/except IntegrityError to rollback and continue on concurrent seed conflicts.
Transaction API change
backend/database_handler/transactions_processor.py
insert_transaction now returns transaction_hash (signature changed from -> None to -> str).
Greyboxing mock result shaping
backend/validators/greyboxing.lua
When using ctx.host_data.mock_response, construct and return a result shaped like exec_prompt_in_provider (stringify table data when needed, preserve consumed_gen) instead of returning preformatted mock entries.
Tests updated for Manager flow
tests/unit/test_simulator_sessions.py, tests/unit/test_validators_init.py, tests/unit/consensus/test_base.py
Replace patched ModifiableValidatorsRegistry usage with injected validators_manager (SimpleNamespace registry), add AccountsManager/provider mocks for init flow, update assertions, and add interval=0.01 to one rotation assertion.
Integration schema adjustments
tests/integration/icontracts/schemas/call_contract_function.py
Change leader_receipt[0].node_config.private_key and primary_model.fallback_validator types from str to Optional[str].
CI workflow changes
.github/workflows/backend_integration_tests_pr.yml
Set VITE_FINALITY_WINDOW=10, add COMPOSE_* mem/cpu env values via sed, and include consensus-worker in Docker Compose startup alongside jsonrpc and database-migration.

Sequence Diagram(s)

sequenceDiagram
    participant RPC as RPC Endpoint
    participant Manager as validators.Manager
    participant Registry as ModifiableValidatorsRegistry
    participant Redis as Redis Pub/Sub
    participant Worker as Consensus Worker

    RPC->>Manager: create/update/delete (injected dependency)
    Manager->>Registry: registry.create/update/delete(...)
    Registry->>Registry: DB commit
    Manager->>Redis: publish {"event":..., "data":...} on validator:events
    Redis-->>Worker: validator:events message
    Worker->>Manager: subscribed callback invoked → restart() validators
    Note right of Worker: background listener runs in redis handler
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Pay extra attention to notifier publish error handling and async behavior.
  • Verify subscription listener lifecycle (task cancellation, unsubscribe, cleanup).
  • Review initialize_validators refactor (AccountsManager, provider selection, error paths).
  • Confirm session.expire_all() is correct/safe for transactional contexts.
  • Validate tests/mocks for the new manager injection and race conditions.

Possibly related PRs

"🐰
I nibbled logs and twitched my nose,
Sent events down Redis where the wild wind blows.
Manager hums and workers leap,
Validators wake from gentle sleep,
Hooray, the garden's tidy rows!"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'fix: broken ci test' is overly generic and does not accurately capture the substantial scope of changes in this PR, which includes Redis-based event subscriptions, validator manager refactoring, and distributed consensus worker architecture. Consider a more descriptive title that reflects the main architectural changes, such as 'feat: add redis-based validator event subscriptions and consensus worker support' or 'fix(ci): add consensus-worker service and validator event propagation'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is comprehensive and well-structured, following the provided template with all major sections filled out including What, Why, Testing done, and Checks completed.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dxp-699-fix-broken-ci-test

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99594b2 and 8803ea0.

📒 Files selected for processing (1)
  • .github/workflows/backend_integration_tests_pr.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/backend_integration_tests_pr.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: load-test
  • GitHub Check: test
  • GitHub Check: backend-unit-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

…so consensus sees updated validators snapshot
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
23.4% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@kstroobants
kstroobants requested review from cristiam86 and removed request for cristiam86 October 21, 2025 11:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
backend/validators/__init__.py (1)

95-126: Validator registry interceptor correctly notifies on post-commit mutations, but relies on per-call Redis connections

The interceptor wiring (create/update/delete/delete_all) correctly wraps mutations in do_write(), commits the session, and only then calls _notify_validator_change(...), which is exactly what you want for side-effectful notifications that must not affect DB semantics.

The remaining concern is that _notify_validator_change currently opens and closes a fresh Redis client on each call via redis.asyncio.from_url(...). Under higher validator churn this adds unnecessary connection overhead and risk of exhaustion compared to reusing a single async client on Manager and closing it in terminate(). This was already raised in a previous review; consider centralizing the client on the manager and switching this code to await self._redis_client.publish(...).

.github/workflows/backend_integration_tests_pr.yml (1)

53-57: Make .env overrides idempotent and align CPU limits with runner capacity

The sed replacements here still assume the keys already exist in .env and hard-code COMPOSE_CPU_LIMIT="4":

sed -i "s/VITE_FINALITY_WINDOW=\".*\"/VITE_FINALITY_WINDOW=\"10\"/" .env
sed -i "s/COMPOSE_CPU_LIMIT=\".*\"/COMPOSE_CPU_LIMIT=\"4\"/" .env
...

Two follow-ups (previously raised) are still worth considering:

  • Make the overrides “replace or append” so they work even if the keys are missing from .env.example.
  • Reduce COMPOSE_CPU_LIMIT to match the 2 vCPUs on ubuntu-latest runners to avoid oversubscription.

A small shell loop that does “if key exists, replace; else append” would make this block more robust, and lowering CPU limit keeps resources aligned with the runner.

🧹 Nitpick comments (1)
tests/unit/test_simulator_sessions.py (1)

176-299: Tests correctly cover validators_manager wiring; consider aligning fakes and cleaning unused args

The updated tests for create_validator, create_random_validators, and update_validator now pass a validators_manager = SimpleNamespace(registry=registry_instance) and assert against registry_instance calls. That’s a good, focused way to verify that endpoint logic uses the injected manager/registry rather than constructing its own instances.

Two small cleanups you may want to make:

  • fake_check_provider_is_available (Lines 275-276) no longer matches the real check_provider_is_available(validators_manager, provider) signature and its parameters are unused. Updating it to async def fake_check_provider_is_available(_validators_manager, _provider): ... will both mirror the actual API and satisfy Ruff’s ARG001.
  • Similarly, where monkeypatch is unused (e.g., in test_delete_all_validators_uses_request_session), renaming to _monkeypatch or dropping the parameter will silence the warning.

Behavior is fine as-is; these are just small maintenance wins.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a56ce6 and a97e299.

📒 Files selected for processing (8)
  • .github/workflows/backend_integration_tests_pr.yml (2 hunks)
  • backend/consensus/worker_service.py (1 hunks)
  • backend/protocol_rpc/endpoints.py (5 hunks)
  • backend/protocol_rpc/rpc_methods.py (3 hunks)
  • backend/validators/__init__.py (3 hunks)
  • backend/validators/greyboxing.lua (1 hunks)
  • docker-compose.yml (3 hunks)
  • tests/unit/test_simulator_sessions.py (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • backend/validators/greyboxing.lua
  • docker-compose.yml
  • backend/consensus/worker_service.py
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Target Python 3.12, use 4-space indentation, and rely on Black (via pre-commit) for formatting

Files:

  • backend/validators/__init__.py
  • backend/protocol_rpc/endpoints.py
  • backend/protocol_rpc/rpc_methods.py
  • tests/unit/test_simulator_sessions.py
tests/{unit,integration,e2e,load}/**

📄 CodeRabbit inference engine (AGENTS.md)

Organize Pytest suites by scope under tests/{unit,integration,e2e,load}

Files:

  • tests/unit/test_simulator_sessions.py
tests/{unit,integration,e2e,load}/test_*.py

📄 CodeRabbit inference engine (AGENTS.md)

Name backend tests as test_.py in the nearest scope folder

Files:

  • tests/unit/test_simulator_sessions.py
🧠 Learnings (1)
📚 Learning: 2025-09-30T10:34:33.826Z
Learnt from: CR
Repo: genlayerlabs/genlayer-studio PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-30T10:34:33.826Z
Learning: Applies to docker-compose*.yml : Use docker-compose*.yml files for composing services

Applied to files:

  • .github/workflows/backend_integration_tests_pr.yml
🧬 Code graph analysis (4)
backend/validators/__init__.py (4)
backend/protocol_rpc/endpoints.py (2)
  • delete_validator (336-345)
  • delete_all_validators (349-353)
backend/protocol_rpc/rpc_methods.py (2)
  • delete_validator (183-190)
  • delete_all_validators (194-197)
backend/database_handler/validators_registry.py (2)
  • delete_validator (92-96)
  • delete_all_validators (98-100)
backend/protocol_rpc/message_handler/redis_worker_handler.py (1)
  • close (234-239)
backend/protocol_rpc/endpoints.py (3)
backend/validators/__init__.py (5)
  • Manager (142-378)
  • create_validator (95-100)
  • update_validator (102-110)
  • delete_validator (112-119)
  • delete_all_validators (121-126)
backend/protocol_rpc/rpc_methods.py (5)
  • create_validator (103-122)
  • update_validator (160-179)
  • delete_validator (183-190)
  • delete_all_validators (194-197)
  • get_all_validators (201-204)
backend/database_handler/validators_registry.py (5)
  • create_validator (70-74)
  • update_validator (76-90)
  • delete_validator (92-96)
  • delete_all_validators (98-100)
  • get_all_validators (51-57)
backend/protocol_rpc/rpc_methods.py (3)
backend/protocol_rpc/dependencies.py (1)
  • get_validators_manager (121-126)
backend/protocol_rpc/endpoints.py (4)
  • create_validator (196-232)
  • update_validator (295-332)
  • delete_validator (336-345)
  • delete_all_validators (349-353)
backend/validators/__init__.py (4)
  • create_validator (95-100)
  • update_validator (102-110)
  • delete_validator (112-119)
  • delete_all_validators (121-126)
tests/unit/test_simulator_sessions.py (2)
backend/protocol_rpc/endpoints.py (3)
  • delete_validator (336-345)
  • delete_all_validators (349-353)
  • get_all_validators (356-357)
backend/protocol_rpc/rpc_methods.py (3)
  • delete_validator (183-190)
  • delete_all_validators (194-197)
  • get_all_validators (201-204)
🪛 Ruff (0.14.5)
backend/validators/__init__.py

377-377: Do not catch blind exception: Exception

(BLE001)


378-378: Use logging.exception instead of logging.error

Replace with exception

(TRY400)

backend/protocol_rpc/rpc_methods.py

111-111: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


168-168: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


185-185: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


195-195: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

tests/unit/test_simulator_sessions.py

275-275: Unused function argument: provider

(ARG001)


275-275: Unused function argument: model

(ARG001)


351-351: Unused function argument: monkeypatch

(ARG001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: load-test
  • GitHub Check: test
  • GitHub Check: backend-unit-tests
🔇 Additional comments (2)
backend/protocol_rpc/endpoints.py (1)

196-353: Validator CRUD endpoints now correctly route through validators_manager.registry

The refactor to inject validators_manager and delegate all validator mutations to validators_manager.registry in:

  • create_validator (Lines 196-233),
  • create_random_validator and create_random_validators (Lines 235-291),
  • update_validator (Lines 295-333),
  • delete_validator and delete_all_validators (Lines 335-353),

looks solid:

  • Mutations go through ModifiableValidatorsRegistryInterceptor, so they benefit from the do_write() locking, snapshot refresh, and Redis-based change notifications added in backend.validators.Manager.
  • You still use the request-scoped Session for account creation and provider registry access, preserving per-request DB scoping.
  • After delete_all_validators, the follow-up get_all_validators() call will see an empty set due to session.expire_all() in the registry, avoiding accidental leakage of any previous state.

This wiring matches the PR goal of centralizing validator lifecycle under the shared manager.

backend/protocol_rpc/rpc_methods.py (1)

102-198: RPC layer correctly propagates validators_manager to validator endpoints

For sim_createValidator, sim_updateValidator, sim_deleteValidator, and sim_deleteAllValidators, the added validators_manager=Depends(get_validators_manager) parameter and corresponding forwarding into impl.* ensure that all validator mutations now go through the shared validators.Manager instance.

This keeps the FastAPI surface aligned with the new manager-based implementation in endpoints.py and guarantees that snapshots and Redis notifications are triggered consistently from RPC calls. Ruff’s B008 warnings here are expected for FastAPI DI patterns and can be ignored.

Comment on lines +342 to +378
async def _notify_validator_change(self, event_type: str, data: dict):
"""
Notify other services about validator changes via Redis.
This is only called by RPC service (not consensus-worker).
"""
import json
import os
import redis.asyncio as aioredis

# Get Redis URL from environment
redis_url = os.environ.get("REDIS_URL", "redis://redis:6379/0")

try:
# Create Redis client for publishing
redis_client = aioredis.from_url(
redis_url, encoding="utf-8", decode_responses=True
)

# Prepare message
message = json.dumps(
{
"event": event_type,
"data": data,
}
)

# Publish to validator events channel for consensus-worker
subscribers = await redis_client.publish("validator:events", message)

# Close the client
await redis_client.close()

logger.info(
f"Published validator change event: {event_type} to {subscribers} subscribers"
)
except Exception as e:
logger.error(f"Failed to publish validator change event: {e}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Improve Redis notifier robustness and logging (avoid blind Exception, prefer logger.exception)

Catching a bare Exception and logging via logger.error loses the stack trace and trips Ruff BLE001/TRY400. Since this notifier is already best-effort and should never break validator CRUD, you can keep failures non-fatal but still tighten things up:

  • Prefer logger.exception("Failed to publish validator change event") to capture the traceback.
  • Optionally narrow the except to Redis-specific errors (e.g. redis.exceptions.RedisError) if you want to avoid suppressing unrelated programming errors.

This keeps behavior the same (no re-raise) while improving diagnosability and satisfying the linter.

🧰 Tools
🪛 Ruff (0.14.5)

377-377: Do not catch blind exception: Exception

(BLE001)


378-378: Use logging.exception instead of logging.error

Replace with exception

(TRY400)

🤖 Prompt for AI Agents
In backend/validators/__init__.py around lines 342 to 378, the current code
catches a bare Exception and logs with logger.error which loses traceback and
trips linters; change the except block to catch Redis-specific errors (e.g.,
except aioredis.exceptions.RedisError as e: or except aioredis.RedisError as e:)
and replace logger.error with logger.exception("Failed to publish validator
change event") so the traceback is recorded; do not re-raise so notifier remains
best-effort, and allow non-Redis exceptions to surface (so programming errors
aren't silently swallowed).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/backend_integration_tests_pr.yml (1)

52-55: Guard OPENAIKEY substitution and reduce CPU limits to fit runner capacity.

Line 52 attempts to substitute OPENAIKEY even on forks where the secret is unavailable, which will inject an empty placeholder. Additionally, COMPOSE_RPC_CPU_LIMIT and COMPOSE_WORKER_CPU_LIMIT are both set to "4" (lines 54–55), exceeding the GitHub runner's 2 vCPU capacity and risking resource exhaustion.

Apply this diff:

       - name: Set OPENAIKEY in the .env file so it can be loaded from the environment
         env:
           OPENAIKEY: ${{ secrets.OPENAIKEY }}
         run: |
-          sed -i "s/<add_your_openai_api_key_here>/${OPENAIKEY}/g" .env
-          sed -i "s/VITE_FINALITY_WINDOW=\".*\"/VITE_FINALITY_WINDOW=\"10\"/" .env
-          sed -i "s/COMPOSE_RPC_CPU_LIMIT=\".*\"/COMPOSE_RPC_CPU_LIMIT=\"4\"/" .env
-          sed -i "s/COMPOSE_WORKER_CPU_LIMIT=\".*\"/COMPOSE_WORKER_CPU_LIMIT=\"4\"/" .env
+          if [ -n "$OPENAIKEY" ]; then
+            sed -i "s/<add_your_openai_api_key_here>/${OPENAIKEY}/g" .env
+          fi
+          sed -i "s/VITE_FINALITY_WINDOW=\".*\"/VITE_FINALITY_WINDOW=\"10\"/" .env
+          sed -i "s/COMPOSE_RPC_CPU_LIMIT=\".*\"/COMPOSE_RPC_CPU_LIMIT=\"2\"/" .env
+          sed -i "s/COMPOSE_WORKER_CPU_LIMIT=\".*\"/COMPOSE_WORKER_CPU_LIMIT=\"2\"/" .env
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6081d0a and 99594b2.

📒 Files selected for processing (1)
  • .github/workflows/backend_integration_tests_pr.yml (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-30T10:34:33.826Z
Learnt from: CR
Repo: genlayerlabs/genlayer-studio PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-30T10:34:33.826Z
Learning: Applies to docker-compose*.yml : Use docker-compose*.yml files for composing services

Applied to files:

  • .github/workflows/backend_integration_tests_pr.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: load-test
  • GitHub Check: test
  • GitHub Check: backend-unit-tests
🔇 Additional comments (1)
.github/workflows/backend_integration_tests_pr.yml (1)

81-81: Build and deploy consensus-worker service.

The addition of consensus-worker to both the Docker Buildx bake targets (line 81) and the compose up command (line 89) is consistent and aligns with the PR's objective to deploy the consensus-worker for validator change event handling.

Also applies to: 89-89

Comment on lines +56 to +61
sed -i "s/COMPOSE_RPC_MEM_RESERVATION=\".*\"/COMPOSE_RPC_MEM_RESERVATION=\"1\"/" .env
sed -i "s/COMPOSE_WORKER_MEM_RESERVATION=\".*\"/COMPOSE_WORKER_MEM_RESERVATION=\"1\"/" .env
sed -i "s/COMPOSE_RPC_MEM_LIMIT=\".*\"/COMPOSE_RPC_MEM_LIMIT=\"6gb\"/" .env
sed -i "s/COMPOSE_WORKER_MEM_LIMIT=\".*\"/COMPOSE_WORKER_MEM_LIMIT=\"6gb\"/" .env
sed -i "s/COMPOSE_RPC_MEM_RESERVATION=\".*\"/COMPOSE_RPC_MEM_RESERVATION=\"2gb\"/" .env
sed -i "s/COMPOSE_WORKER_MEM_RESERVATION=\".*\"/COMPOSE_WORKER_MEM_RESERVATION=\"2gb\"/" .env

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Resolve conflicting memory reservation values and make .env updates idempotent.

Lines 56–57 set COMPOSE_RPC_MEM_RESERVATION and COMPOSE_WORKER_MEM_RESERVATION to "1", but lines 60–61 immediately overwrite them to "2gb". This is logically conflicting and suggests a copy-paste error. Additionally, the sed pattern only updates existing keys; if a key is absent from .env, it won't be added, leaving variables unset during CI.

Apply this diff to remove the duplicate/conflicting lines and make the configuration idempotent:

           sed -i "s/VITE_FINALITY_WINDOW=\".*\"/VITE_FINALITY_WINDOW=\"10\"/" .env
           sed -i "s/COMPOSE_RPC_CPU_LIMIT=\".*\"/COMPOSE_RPC_CPU_LIMIT=\"2\"/" .env
           sed -i "s/COMPOSE_WORKER_CPU_LIMIT=\".*\"/COMPOSE_WORKER_CPU_LIMIT=\"2\"/" .env
-          sed -i "s/COMPOSE_RPC_MEM_RESERVATION=\".*\"/COMPOSE_RPC_MEM_RESERVATION=\"1\"/" .env
-          sed -i "s/COMPOSE_WORKER_MEM_RESERVATION=\".*\"/COMPOSE_WORKER_MEM_RESERVATION=\"1\"/" .env
           sed -i "s/COMPOSE_RPC_MEM_LIMIT=\".*\"/COMPOSE_RPC_MEM_LIMIT=\"6gb\"/" .env
           sed -i "s/COMPOSE_WORKER_MEM_LIMIT=\".*\"/COMPOSE_WORKER_MEM_LIMIT=\"6gb\"/" .env
-          sed -i "s/COMPOSE_RPC_MEM_RESERVATION=\".*\"/COMPOSE_RPC_MEM_RESERVATION=\"2gb\"/" .env
-          sed -i "s/COMPOSE_WORKER_MEM_RESERVATION=\".*\"/COMPOSE_WORKER_MEM_RESERVATION=\"2gb\"/" .env
+          sed -i "s/COMPOSE_RPC_MEM_RESERVATION=\".*\"/COMPOSE_RPC_MEM_RESERVATION=\"2gb\"/" .env
+          sed -i "s/COMPOSE_WORKER_MEM_RESERVATION=\".*\"/COMPOSE_WORKER_MEM_RESERVATION=\"2gb\"/" .env
+
+          # Make updates idempotent: append if key is missing
+          for key in VITE_FINALITY_WINDOW COMPOSE_RPC_CPU_LIMIT COMPOSE_WORKER_CPU_LIMIT COMPOSE_RPC_MEM_RESERVATION COMPOSE_WORKER_MEM_RESERVATION COMPOSE_RPC_MEM_LIMIT COMPOSE_WORKER_MEM_LIMIT; do
+            if ! grep -q "^${key}=" .env; then
+              echo "${key}=\"\"" >> .env
+            fi
+          done

Alternatively, refactor to a loop with replace-or-append logic for all variables at once (cleaner but more complex).

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In .github/workflows/backend_integration_tests_pr.yml around lines 56 to 61,
there are duplicate/conflicting sed updates that first set
COMPOSE_RPC_MEM_RESERVATION/COMPOSE_WORKER_MEM_RESERVATION to "1" and then
overwrite them to "2gb" (likely a copy/paste error) and the sed commands only
replace existing keys (they won't add missing keys). Remove the
duplicate/conflicting lines so each variable is set once to the intended value,
and replace the per-key sed calls with idempotent replace-or-append logic (or a
small loop) that updates the key if present and appends KEY="value" if missing
so the .env changes are deterministic and safe for CI.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
25.3% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@cristiam86
cristiam86 merged commit ef905de into main Nov 20, 2025
1 check passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.81.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants