From a7b06c46a67f9407ff869674436b9ba79b7ade76 Mon Sep 17 00:00:00 2001 From: Domen Grabec Date: Tue, 28 Jul 2026 01:28:32 +0200 Subject: [PATCH] fix: stop the schedule seed overwriting operator edits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #2848 changed the seed's conflict clause to DO UPDATE SET command so the 46 existing rows would migrate from `pnpm hardhat ` to the new `pnpm exec tsx tasks/run.ts ` invocation. Seeds re-run on every runner boot, so that also silently overwrote parameters operators had set in the admin UI: on 2026-07-27 the deploy reset all 46 rows to stock defaults, losing the flags on stake_validator and remove_validator. The migration it was added for has now completed — the seed applied on the 23:15:59Z boot, so every row already carries the tsx invocation. Reverting to DO NOTHING therefore loses nothing and stops future deploys from clobbering operator state. cron_expr, enabled and signer_override were never in the clause and were unaffected throughout. Also drop the duplicate seed application in runner.ts: runContainer already applies every migrations/seed_*.sql before starting the scheduler, so this ran the same file twice per boot and bypassed the client-side seed validation. --- contracts/migrations/seed_schedules.sql | 2 +- contracts/runner.ts | 26 +++++-------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/contracts/migrations/seed_schedules.sql b/contracts/migrations/seed_schedules.sql index f535f1dc02..65fe42ef53 100644 --- a/contracts/migrations/seed_schedules.sql +++ b/contracts/migrations/seed_schedules.sql @@ -57,4 +57,4 @@ INSERT INTO schedules (product, name, command, cron_expr, timezone, enabled, not ('origin-dollar', 'ousd_rebalancer', 'cd /app && pnpm exec tsx tasks/run.ts ousdRebalancer --network mainnet', '0 0 1 1 *', 'UTC', false, 'Manual: Run now to rebalance OUSD Morpho strategies'), ('origin-dollar', 'queue_proposal', 'cd /app && pnpm exec tsx tasks/run.ts queueGovernorSixProposal --network mainnet', '0 0 1 1 *', 'UTC', false, 'Manual: add --propid then Run now'), ('origin-dollar', 'execute_proposal', 'cd /app && pnpm exec tsx tasks/run.ts executeGovernorSixProposal --network mainnet', '0 0 1 1 *', 'UTC', false, 'Manual: add --propid then Run now') -ON CONFLICT (product, name) DO UPDATE SET command = EXCLUDED.command; +ON CONFLICT (product, name) DO NOTHING; diff --git a/contracts/runner.ts b/contracts/runner.ts index e5a3bac557..6fcf9561b1 100644 --- a/contracts/runner.ts +++ b/contracts/runner.ts @@ -1,32 +1,16 @@ import { existsSync, readFileSync } from "node:fs"; -import { dirname, resolve } from "node:path"; -import { fileURLToPath } from "node:url"; -import { - type ActionsCatalog, - createPool, - runContainer, -} from "@oplabs/talos-client"; +import { type ActionsCatalog, runContainer } from "@oplabs/talos-client"; const databaseUrl = process.env.DATABASE_URL; if (!databaseUrl) { throw new Error("DATABASE_URL env var required"); } -// Apply contracts/migrations/seed_schedules.sql before the runner boots so -// any new schedule rows in that file land in the shared Talos Postgres on -// container start. The file uses INSERT ... ON CONFLICT DO NOTHING, so it -// is safe to re-run on every restart and only adds previously-unseen rows. -const __dirname = dirname(fileURLToPath(import.meta.url)); -const seedSqlPath = resolve(__dirname, "migrations/seed_schedules.sql"); -const seedSql = readFileSync(seedSqlPath, "utf8"); -const pool = createPool({ connectionString: databaseUrl }); -try { - await pool.query(seedSql); - console.log(`[runner] applied ${seedSqlPath}`); -} finally { - await pool.end(); -} +// Seeds are applied by runContainer (@oplabs/talos-client applySeedFiles), +// which reads every /migrations/seed_*.sql before starting the +// scheduler. Applying them here too was redundant, and bypassed the +// client-side validation of seed contents. // The catalog is dumped at image build time by docker/dump-actions-catalog.cjs // (Node, where hardhat works). Reading it here keeps the runner's bun parent