Skip to content

Fix/1526 1528 1543 1544 - #1646

Merged
Junirezz merged 3 commits into
Junirezz:mainfrom
francisdouglas-ux:fix/1526-1528-1543-1544
Oct 18, 2026
Merged

Junirezz merged 3 commits into
Junirezz:mainfrom
francisdouglas-ux:fix/1526-1528-1543-1544

Conversation

@francisdouglas-ux

Copy link
Copy Markdown
Contributor

🚀 Overview

This Pull Request resolves four critical smart contract security, operational governance, and backend documentation issues for Junirezz/YieldVault-RWA:

  1. Bridge Transfer Safety & Limits ([contract] Fix transfer_out balance check to sender + enforce max_transfer #1528): Replaced contract balance checks with sender balance validation and enforced min_transfer / max_transfer bounds in transfer_out.
  2. Timelocked Contract Upgrades ([contract] Add timelocked upgrade + implementation-slot verification #1543): Replaced instant contract upgrades with a 3-step timelock mechanism (propose_upgrade, execute_upgrade, cancel_upgrade) backed by EIP-1967 implementation slot updates and audit events.
  3. Strategy Validation Error Resolution & WASM Build Repair ([contract] Repair strategy_validation / rounding_consistency missing error variants #1526): Resolved missing validation error paths in strategy_validation.rs and rounding_consistency.rs, restoring target release WASM compilation.
  4. Backend OpenAPI Synchronization & Drift Detection ([backend] OpenAPI drift: only 18 paths documented vs 100+ routes #1544): Expanded openapi.json coverage from ~20 to 165 endpoints (including admin, bulk export, impersonation, and event replay routes) and added an automated CI drift check (npm run check:openapi).

🔑 Linked Issues


🛠️ Summary of Changes

🌉 1. Bridge Balance & Transfer Limits (contracts/bridge-compat/src/lib.rs) (#1528)

  • Sender Balance Check: Updated transfer_out to verify the sender address balance rather than env.current_contract_address().
  • Transfer Bounds Enforcement: Enforced min_transfer <= amount <= provider.max_transfer prior to initiating cross-chain transfers in both transfer_out and estimate_transfer.
  • Configurable Min Limit: Added an admin-configurable minimum transfer threshold stored independently to preserve storage compatibility with existing on-chain provider records.
  • Unit Tests: Added 3 unit tests validating over-limit attempts, below-minimum transfers, and underfunded sender conditions.

⏱️ 2. Timelocked Upgrades & EIP-1967 Slot Writes (contracts/vault/src/) (#1543)

  • 3-Step Upgrade Pipeline: Replaced direct upgrade() with a staged flow: propose_upgrade (staging WASM hash with a 24-hour delay or configured timelock), execute_upgrade, and cancel_upgrade.
  • EIP-1967 Verification: On execution, writes the new WASM hash to IMPLEMENTATION_SLOT and reads it back to verify storage integrity. Emergency force-upgrade paths also populate the slot.
  • Audit Events: Emits upg_prop, upg_cncl, and upgraded audit events.
  • Unit Tests: Added 6 tests covering timelock enforcement, slot verification, audit event generation, and admin authorization bounds.

🛡️ 3. Validation Error Alignment & WASM Build Fix (contracts/vault/src/) (#1526)

  • Release WASM Repair: Fixed compilation failures in strategy_validation.rs, restoring successful release WASM builds (cargo build --target wasm32v1-none --release).
  • Error Variant Coverage: Added 5 unit tests validating exact error returns across all paths in strategy_validation.rs and rounding_consistency.rs.

📜 4. Backend OpenAPI Sync & CI Drift Check (backend/) (#1544)

  • OpenAPI Expansion: Updated backend/openapi.json to document 165 API operations (up from 18), covering /admin/exports/bulk, /admin/impersonate/*, /admin/events/replay, and /api/v1/admin/diagnostics.
  • CI Drift Guard: Updated generate-openapi script with --check --fail-on-drift flag and wired npm run check:openapi into CI.
  • Backend Source Cleanup: Reconciled base64-encoded file corruption (healthProbe.ts, apiKeyAuth.ts), removed duplicate merge blocks across 8 backend utilities, fixed dependency typos, and normalized package.json.

📁 Files Touched

File / Path Change Summary
contracts/bridge-compat/src/lib.rs Sender balance validation, transfer limit checks, and min_transfer configuration.
contracts/vault/src/lib.rs & upgrade.rs Timelocked upgrade implementation, EIP-1967 slot writes, and audit event logs.
contracts/vault/src/strategy_validation.rs Repaired compilation paths and error handling branches.
backend/openapi.json Expanded API schema definition from 18 to 165 endpoints.
backend/scripts/generate-openapi.ts Added --check --fail-on-drift flags for CI drift validation.
backend/src/ Reconciled merged duplicates, fixed base64 file corruptions, and wired diagnostics endpoints.

🧪 Verification Logs

  • Bridge Contracts: All 12 bridge-compat unit and limit tests passed cleanly.
  • Vault Contracts: All 11 new/modified unit tests (timelocks, slot checks, validation errors) passed. Release WASM builds cleanly.
  • Backend OpenAPI: All 18 OpenAPI generator and schema tests passed; npm run check:openapi passes locally without drift.

⚠️ Notes for Maintainers

  1. Vault Route Selection (GET /vaults query does not enforce max limit and allows limit=100000 to OOM the API #1430): routes/vaults.ts contained duplicate glued definitions. We retained the public page-limited implementation from GET /vaults query does not enforce max limit and allows limit=100000 to OOM the API #1430 to match swagger.ts.
  2. Prisma Schema Notice: The Prisma schema contains a duplicate ApiKey model definition causing prisma generate to fail in CI. A database cleanup PR should decide which ApiKey model and migration to retain.
  3. Upstream Rebase: This branch shares foundational storage and compilation repairs with the godamongstmen897 branch; whichever PR merges second can rebase cleanly.

…idation build

- bridge-compat: transfer_out checks the sender's balance instead of the
  contract's and enforces min_transfer <= amount <= provider.max_transfer
  (shared with estimate_transfer); admin-settable min_transfer (Junirezz#1528)
- vault: replace instant upgrade with propose_upgrade / execute_upgrade /
  cancel_upgrade behind max(24h, sensitive timelock); write and verify the
  EIP-1967 implementation slot and emit upg_prop / upg_cncl / upgraded;
  emergency ForceUpgrade also records the slot (Junirezz#1543)
- vault: strategy_validation builds for wasm (zero address from strkey);
  exact-error unit tests for every strategy_validation and
  rounding_consistency error path; docs list the real error codes (Junirezz#1526)
- fix pre-existing compile errors in rounding.rs, total_assets, the
  bridge-compat test module and vault lib tests so the tests run

Closes Junirezz#1526
Closes Junirezz#1528
Closes Junirezz#1543
- generate-openapi: repair the script and add --check / --fail-on-drift,
  which load the app, diff every operation against openapi.json and exit
  non-zero on drift or when the app cannot be loaded; npm run check:openapi
  replaces the git-status check in backend-governance CI
- regenerate openapi.json from the router stack (165 operations, incl.
  /admin/exports/bulk, /admin/impersonate/*, /admin/events/replay) and
  mount the existing diagnostics handler at GET /api/v1/admin/diagnostics
- repair the corruption that kept src/index.ts from loading: base64-encoded
  healthProbe.ts / apiKeyAuth.ts, duplicated merge blocks in eventOutbox,
  idempotency (store now only re-exported from idempotencyStore), apiError,
  pagination, tracing, outboxPoller, vaultEndpoints and routes/vaults (keeps
  the Junirezz#1430 public listing), the @yieldvault/api-schemas dependency name,
  the lockfile, and a trailing comma in the root package.json

Closes Junirezz#1544
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@francisdouglas-ux Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Junirezz
Junirezz merged commit 3acbd38 into Junirezz:main Oct 18, 2026
13 of 29 checks passed
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

res: Response,
next: NextFunction
): Promise<void> {
const authHeader = req.get?.('Authorization') || '';
});
}

export function hashApiKey(key: string): string {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants