Skip to content

Commit 990a6c1

Browse files
Merge branch 'main' into Resolved
2 parents ca14ea1 + fbf996b commit 990a6c1

152 files changed

Lines changed: 9902 additions & 646 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

IMPLEMENTATION_COMPLETE.md

Lines changed: 440 additions & 0 deletions
Large diffs are not rendered by default.

IMPLEMENTATION_SUMMARY.md

Lines changed: 502 additions & 0 deletions
Large diffs are not rendered by default.

PR_MESSAGE.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Add Secure Admin-Controlled Contract Upgrade (Safe Upgrade Pattern)
2+
3+
## Summary
4+
5+
This PR implements a secure, admin-controlled contract upgrade pattern ("Safe Upgrade" / Admin Proxy) for the VaultixEscrow Soroban contract. It allows protocol maintainers to fix bugs or add features without migrating all state and users to a new contract address.
6+
7+
## Key Changes
8+
9+
- **Upgrade Functionality:**
10+
- Added `upgrade(env, new_wasm_hash: [u8; 32])` to the contract, callable only by the admin.
11+
- Emits a `ContractUpgraded` event before performing the upgrade.
12+
- Enforces strict access control (admin-only).
13+
- Documents storage compatibility requirements for future upgrades.
14+
15+
- **Testing:**
16+
- Integration test verifies:
17+
- State is preserved across upgrades.
18+
- Unauthorized users cannot trigger upgrades.
19+
- New contract logic is accessible after upgrade.
20+
21+
## Motivation
22+
23+
Soroban allows contract upgrades via `env.deployer().update_current_contract_wasm`. This PR wraps that capability in a secure, admin-controlled function to ensure only authorized upgrades, protecting user funds and protocol integrity.
24+
25+
## Acceptance Criteria
26+
27+
- [x] `upgrade` function exists and is admin-protected.
28+
- [x] Emits upgrade event.
29+
- [x] Storage compatibility is documented.
30+
- [x] Integration test proves code can be swapped while keeping escrow storage intact.
31+
- [x] Unauthorized users cannot trigger an upgrade.
32+
33+
## Non-Goals
34+
35+
- DAO-voting based upgrades (admin-only for now).
36+
37+
---
38+
39+
**Reviewer Notes:**
40+
- Please review the storage compatibility comment for future upgrade safety.
41+
- All tests pass (`cargo test`).
42+
- No breaking changes to existing escrow logic.
43+
44+
---

apps/backend/.env.example

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# Database Configuration
22
DATABASE_PATH=./data/vaultix.db
33

4-
# JWT Configuration
5-
JWT_SECRET=your-super-secret-jwt-key-change-in-production
4+
# JWT Configuration (Required at startup, minimum 32 characters long)
5+
JWT_SECRET=your-32-character-minimum-super-secret-key-here
66
JWT_EXPIRES_IN=15m
77

88
# Environment
99
NODE_ENV=development
1010

1111
# Server Configuration
1212
PORT=3000
13+
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001
14+
15+
# Health Check Configuration
16+
# Max time (ms) each dependency probe may take before being reported as down
17+
HEALTH_CHECK_TIMEOUT_MS=5000
1318

1419
# Stellar Configuration
1520
STELLAR_NETWORK=testnet
@@ -24,6 +29,23 @@ SMTP_PORT=587
2429
SMTP_USER=your-smtp-user
2530
SMTP_PASS=your-smtp-password
2631
EMAIL_FROM=no-reply@vaultix.io
32+
EMAIL_MAX_ATTEMPTS=5
33+
EMAIL_RETRY_BASE_DELAY_MS=60000
34+
35+
# Webhook Delivery Configuration
36+
# Max delivery attempts before a webhook moves to the dead letter queue
37+
WEBHOOK_MAX_ATTEMPTS=6
38+
# Backoff schedule in ms (1m, 5m, 30m, 2h, 12h, 24h)
39+
WEBHOOK_RETRY_SCHEDULE_MS=60000,300000,1800000,7200000,43200000,86400000
40+
# Outbound request timeout in ms
41+
WEBHOOK_REQUEST_TIMEOUT_MS=30000
42+
# Alert when failure rate (%) in the window exceeds this threshold
43+
WEBHOOK_ALERT_FAILURE_RATE_THRESHOLD=25
44+
WEBHOOK_ALERT_MIN_DELIVERIES=10
45+
WEBHOOK_ALERT_WINDOW_MINUTES=60
46+
# Base URL used to build email verification links (defaults to API_BASE_URL + /auth/profile/verify-email)
47+
API_BASE_URL=http://localhost:3000
48+
#EMAIL_VERIFICATION_BASE_URL=https://app.vaultix.io/verify-email
2749

2850
# App Version Gating
2951
APP_MIN_SUPPORTED_VERSION=1.0.0

apps/backend/jest-setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'reflect-metadata';

0 commit comments

Comments
 (0)