Skip to content

fix(indexer): remove legacy monitored value monitors#3311

Open
baktun14 wants to merge 1 commit into
mainfrom
fix/indexer-remove-monitored-value
Open

fix(indexer): remove legacy monitored value monitors#3311
baktun14 wants to merge 1 commit into
mainfrom
fix/indexer-remove-monitored-value

Conversation

@baktun14

@baktun14 baktun14 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Why

The indexer's DeploymentBalanceMonitor has been throwing non-stop in production — Sentry CLOUDMOS-SYNCER-5C, 5180+ events since 2026-05-08 — whenever it can't fetch a deployment's escrow balance.

That monitor and its sibling AddressBalanceMonitor are leftovers from the old Blockspy/Cloudmos system (the indexer README flagged them "Blockspy specific" and "not used in the deploy tool"). Nothing in the monorepo reads the monitoredValue table they write to, so the whole feature is dead weight that only generates error noise.

Fixes CLOUDMOS-SYNCER-5C

What

Removes the legacy MonitoredValue feature end to end:

  • Deleted both monitors (apps/indexer/src/monitors/) and unregistered their scheduled tasks in index.ts.
  • Removed the MonitoredValue.sync() call (buildDatabase.ts) and the shared Sequelize model (packages/database), including its entry in baseModels — also consumed by apps/api, which never queries the table (verified, type-checks clean).
  • Cleaned the table from the Drizzle schema.ts and removed the two task rows from the indexer README.

⚠️ Production DB migration: 0009_drop_monitored_value.sql runs DROP TABLE IF EXISTS "monitoredValue". No code in this PR reads or writes the table anymore, so the drop is non-blocking and safe. Historical migrations and meta/ snapshots are intentionally left intact as immutable history.

Summary by CodeRabbit

  • Bug Fixes
    • Removed obsolete balance-monitoring tasks from the scheduler list.
    • Cleaned up the indexer by dropping the legacy monitored-value data storage.
  • Chores
    • Updated documentation to match the current scheduled task list.
    • Removed unused database schema references related to monitored values.

The Address/Deployment Balance Monitors are leftovers from the old
Blockspy/Cloudmos system and are unused by the deploy tool. The
DeploymentBalanceMonitor in particular has been throwing non-stop
(5180+ events) whenever it can't fetch a deployment's escrow balance.

Nothing in the monorepo reads the monitoredValue table, so this removes
the two monitors, their scheduled tasks, the shared Sequelize model, and
drops the table via migration 0009.

Fixes CLOUDMOS-SYNCER-5C
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR removes the monitoredValue database schema and model registration, drops the corresponding migration target table, removes address and deployment balance monitor wiring from the indexer scheduler, and updates the indexer README task list to match.

Changes

Indexer monitored value removal

Layer / File(s) Summary
Drop monitoredValue schema and registration
apps/indexer/drizzle/0009_drop_monitored_value.sql, apps/indexer/drizzle/meta/_journal.json, apps/indexer/drizzle/schema.ts, apps/indexer/src/db/buildDatabase.ts, packages/database/dbSchemas/base/index.ts, packages/database/dbSchemas/base/monitoredValue.ts, packages/database/dbSchemas/index.ts
Adds a migration that drops monitoredValue, removes the Drizzle table and Sequelize model/export wiring, and stops syncing that model during indexer database initialization.
Remove balance monitor wiring
apps/indexer/src/monitors/addressBalanceMonitor.ts, apps/indexer/src/monitors/deploymentBalanceMonitor.ts, apps/indexer/src/monitors/index.ts, apps/indexer/src/index.ts, apps/indexer/README.md
Deletes the address and deployment balance monitor implementations and exports, removes their scheduled task registrations, and removes their entries from the documented scheduled tasks list.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

size: M, experienced-contributor

Suggested reviewers

  • stalniy
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/indexer-remove-monitored-value

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/indexer/drizzle/0009_drop_monitored_value.sql`:
- Line 2: The DROP TABLE IF EXISTS statement for "monitoredValue" on line 2
performs an irreversible hard drop without any safeguard. Add a data-retention
gate before dropping the table by implementing a check that verifies the table
is empty or has no dependent data, causing the migration to fail explicitly if
data still exists rather than silently deleting rows. This can be done by adding
a guard query (such as checking row count) before the DROP TABLE statement, or
implementing a two-phase migration where the table is first marked for
deprecation before being dropped in a subsequent migration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9c91cde2-fdd1-4ef5-a4a0-bd4b3568daf3

📥 Commits

Reviewing files that changed from the base of the PR and between d3c1ed3 and 87d317a.

📒 Files selected for processing (12)
  • apps/indexer/README.md
  • apps/indexer/drizzle/0009_drop_monitored_value.sql
  • apps/indexer/drizzle/meta/_journal.json
  • apps/indexer/drizzle/schema.ts
  • apps/indexer/src/db/buildDatabase.ts
  • apps/indexer/src/index.ts
  • apps/indexer/src/monitors/addressBalanceMonitor.ts
  • apps/indexer/src/monitors/deploymentBalanceMonitor.ts
  • apps/indexer/src/monitors/index.ts
  • packages/database/dbSchemas/base/index.ts
  • packages/database/dbSchemas/base/monitoredValue.ts
  • packages/database/dbSchemas/index.ts
💤 Files with no reviewable changes (9)
  • packages/database/dbSchemas/base/index.ts
  • apps/indexer/src/monitors/addressBalanceMonitor.ts
  • packages/database/dbSchemas/base/monitoredValue.ts
  • apps/indexer/src/monitors/index.ts
  • apps/indexer/src/monitors/deploymentBalanceMonitor.ts
  • apps/indexer/README.md
  • apps/indexer/drizzle/schema.ts
  • apps/indexer/src/index.ts
  • apps/indexer/src/db/buildDatabase.ts

@@ -0,0 +1,2 @@
-- Drop legacy Blockspy monitoredValue table (no longer used)
DROP TABLE IF EXISTS "monitoredValue";

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 | ⚡ Quick win

Add a deprecation/data-retention gate before dropping the table.

Line 2 performs an immediate hard drop, which can irreversibly delete existing monitoredValue rows during rollout/rollback. Add an explicit guard (or two-phase deprecate-then-drop sequence) so the migration fails safely if data still exists.

Proposed migration hardening
 -- Drop legacy Blockspy monitoredValue table (no longer used)
-DROP TABLE IF EXISTS "monitoredValue";
+DO $$
+BEGIN
+  IF EXISTS (SELECT 1 FROM "monitoredValue" LIMIT 1) THEN
+    RAISE EXCEPTION 'monitoredValue is not empty; deprecate/archive before dropping';
+  END IF;
+END
+$$;
+
+DROP TABLE IF EXISTS "monitoredValue";

As per coding guidelines, raw SQL migrations should flag destructive DROP COLUMN/TABLE operations without prior deprecation.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
DROP TABLE IF EXISTS "monitoredValue";
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM "monitoredValue" LIMIT 1) THEN
RAISE EXCEPTION 'monitoredValue is not empty; deprecate/archive before dropping';
END IF;
END
$$;
DROP TABLE IF EXISTS "monitoredValue";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/indexer/drizzle/0009_drop_monitored_value.sql` at line 2, The DROP TABLE
IF EXISTS statement for "monitoredValue" on line 2 performs an irreversible hard
drop without any safeguard. Add a data-retention gate before dropping the table
by implementing a check that verifies the table is empty or has no dependent
data, causing the migration to fail explicitly if data still exists rather than
silently deleting rows. This can be done by adding a guard query (such as
checking row count) before the DROP TABLE statement, or implementing a two-phase
migration where the table is first marked for deprecation before being dropped
in a subsequent migration.

Source: Coding guidelines

@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.42%. Comparing base (d3c1ed3) to head (87d317a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3311      +/-   ##
==========================================
- Coverage   68.81%   67.42%   -1.40%     
==========================================
  Files        1096     1007      -89     
  Lines       26837    24583    -2254     
  Branches     6435     5995     -440     
==========================================
- Hits        18468    16574    -1894     
+ Misses       7326     6997     -329     
+ Partials     1043     1012      -31     
Flag Coverage Δ *Carryforward flag
api 84.83% <ø> (ø)
deploy-web 54.09% <ø> (ø) Carriedforward from d3c1ed3
log-collector ?
notifications 91.44% <ø> (ø) Carriedforward from d3c1ed3
provider-console 81.38% <ø> (ø) Carriedforward from d3c1ed3
provider-inventory ?
provider-proxy 86.37% <ø> (ø) Carriedforward from d3c1ed3
tx-signer ?

*This pull request uses carry forward flags. Click here to find out more.
see 89 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant