Skip to content

Fix/contracts merge corruption - #1092

Merged
joelpeace48-cell merged 2 commits into
mainfrom
fix/contracts-merge-corruption
Jul 29, 2026
Merged

Fix/contracts merge corruption#1092
joelpeace48-cell merged 2 commits into
mainfrom
fix/contracts-merge-corruption

Conversation

@joelpeace48-cell

Copy link
Copy Markdown
Contributor

No description provided.

main has been broken since a series of bad merges landed. This fixes
every currently-failing check on main-branch CI:

- backend/src/jobs/eventIndexer.js: a merge dropped a comment's opening
  `/**` and the Semaphore class's closing `}`, leaving doc-comment text
  as bare tokens. Node can't parse the module, so the backend crashed
  on every boot (root cause of Security Headers Check failing on every
  recent commit).
- backend/src/index.js: two more merge artifacts — `indexerRepository`
  and `defaultRateLimiter` were referenced in the /graphql route wiring
  but never declared anywhere in scope.
- backend/src/db/migrations/037_outbox.js: missing the required
  `version`/`description` exports, so the migration runner threw
  instead of applying it.
- backend/src/db/migrations/038 (new): 026_notification_preferences.js
  and 026_operator_balance_log.js share version 26, so the checked-in
  trivela.db (which already has 26 recorded from whichever file ran
  first) never got notification_channel_settings created, crashing the
  notification repository at boot. Same disease as the existing 034
  backfill migration for the version-13 collision; this heals it the
  same way with a fresh version number.
- .github/workflows/frontend-ci.yml: a bad merge dropped the
  `accessibility` job's `steps:` entirely and spliced its steps into
  `cross-browser-e2e` instead, producing an invalid job with no steps
  and no `uses:` — GitHub can't even schedule the workflow. Split the
  steps back into their own jobs.
- .github/workflows/performance-gate.yml: `actions-rs/toolchain@v1` is
  unmaintained and doesn't install the wasm32-unknown-unknown target
  that `stellar-cli` needs to build. Swapped for `dtolnay/rust-toolchain`
  with the target declared explicitly, matching the working pattern
  already used in ci-performance.yml.
- Repo-wide `prettier --write` per format:check's own globs — 50 files
  had drifted since nobody had run it before committing.

Verified locally: backend now boots clean and GET /health returns 200
with every header Security Headers Check greps for; all workflow YAML
re-validated; `node --check` clean across backend/src.
Both contracts had unclosed-delimiter compile breaks from bad merges
of independently-developed PRs. Traced each via git history to find
the exact original code before it got tangled.

contracts/campaign/src/lib.rs — do_register():
- Two PRs (2efd49e, 15605f0) each rewrote the same referral
  anti-abuse validation with different storage-key schemes. The merge
  left a 3-line orphaned fragment of one version in front of the
  other's complete implementation, and left an if/else branch
  (REFERRAL_LOCK bookkeeping) unclosed — its content then read as
  nested inside code that was meant to be its sibling. Removed the
  dead fragment, closed the branch.
- Error::ReferralLoop was defined twice (same discriminant, two doc
  comments from the two PRs). Merged into one variant covering both
  the direct-cycle and chain-walk detection paths.

contracts/campaign/src/test.rs:
- Two tests (test_referral_lock_prevents_referrer_swap_on_re_register,
  test_referral_loop_direct_cycle_rejected) were truncated mid-body by
  the same merge. Restored each verbatim from the commit that
  originally authored it.

Verified: `cargo check -p trivela-campaign-contract` and
`cargo check -p trivela-campaign-contract --tests` both compile clean
(only pre-existing deprecation warnings, no errors).

Note: running the full `cargo test` suite surfaces ~21 unrelated,
pre-existing errors where tests call contract methods
(register/set_merkle_root) with an outdated argument count/type —
that's separate API drift beyond this merge-corruption fix and needs
its own pass.

contracts/rewards/src/lib.rs — three functions truncated mid-body by
the same class of bad merge (init_multisig, cancel_param_change,
get_param_proposal all cut off before their closing brace, each
verified against the commit that introduced it and restored verbatim).
This resolves the unclosed-delimiter parse failure.

NOT fixed here, needs a maintainer decision:
- Error enum has a genuine 3-way collision across discriminants 21-31:
  a governance-voting multisig scheme (MultiSigNotConfigured..
  ProposalCancelled), a simpler M-of-N multisig scheme matching the
  one already used in the campaign contract (InvalidThreshold..
  UnknownSigner), and the already-published SEP-41 token error block
  (TokenModeNotEnabled..InvalidExpiration, documented in
  docs/CONTRACTS_API.md — renumbering that one breaks existing client
  decoding). A later commit's own comment shows an engineer was aware
  of the SEP-41 collision and dodged it, but not the multisig one.
  Picking a final numbering requires knowing which multisig scheme is
  still wanted, not something to guess in a contract that pays out
  rewards.
- Two unresolved crate imports (ark_bn254, light_poseidon) for what
  looks like an incomplete ZK/nullifier feature — unrelated to the
  merge damage, blocks compilation regardless of the enum fix.
@joelpeace48-cell
joelpeace48-cell merged commit b527d95 into main Jul 29, 2026
12 of 26 checks passed
@joelpeace48-cell
joelpeace48-cell deleted the fix/contracts-merge-corruption branch July 30, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants