Skip to content

Latest commit

 

History

History
843 lines (764 loc) · 50 KB

PRODUCTION.md

File metadata and controls

843 lines (764 loc) · 50 KB

Production Guide

This is the production entry point for Guardian operators. It summarizes the supported production shape and points to the detailed deploy, architecture, configuration, and runbook docs.

Supported shape

Every production Guardian, wherever it runs, has the same shape:

  • The Postgres storage backend: GUARDIAN_SERVER_FEATURES=postgres, plus evm when EVM proposal support is required. Guardian execution is always built in and stays off until a prover is configured. The prover sees every executed transaction's full inputs (private account state, cosigner signatures, Guardian's acknowledgement), so it must be one you trust or host yourself (prover trust). Filesystem mode is a local development backend only: it has no durable admin audit table, no schema migrations, and cannot safely back more than one replica. The prod stage refuses it at startup.
  • GUARDIAN_ENV=prod, which turns on the prod-stage startup guards.
  • A stable ACK signing identity loaded from a secret store or from owner-only key files, never minted per boot.
  • Explicit GUARDIAN_CORS_ALLOWED_ORIGINS for browser clients.
  • Verified TLS to the database, storage encryption where the threat model warrants it, and a metrics endpoint that is never publicly reachable.

The reference deployment, and the recommended one, is AWS ECS/Fargate built by scripts/aws-deploy.sh and the Terraform in infra/: DEPLOY_STAGE=prod selects the stage profile, Amazon RDS holds state, deltas, proposals, account metadata, and audit rows, and AWS Secrets Manager (or KMS for the ECDSA signer) holds the ACK keys and deploy-time secrets.

Running the published Docker image on your own host, VM, or Kubernetes is supported and reaches the same shape. When ECS is not an option, the recommended way to do it keeps secret custody in AWS: the ACK keys in Secrets Manager and KMS, the storage-encryption key document in Secrets Manager, and everything else (Postgres, ingress, backups, metrics) yours (production guide, track C). Running with no AWS account at all is also supported, with file-based ACK keys (written by the image's ack-keygen) and the same rotatable {active, keys} encryption key document in an owner-only file (track B). On both, GUARDIAN_ENV=prod applies the production runtime defaults inside the server, so only the topology-dependent values (GUARDIAN_MAX_REPLICAS, the cursor secret, metrics, CORS) are set by hand; the guide walks through it, including what becomes your responsibility (database backups, TLS termination, client-IP forwarding, metrics scraping).

ECDSA ACK signer: Secrets Manager or KMS

The Falcon and ECDSA ACK keys default to AWS Secrets Manager, which is the path existing deployments use and remains fully supported. For the ECDSA signer specifically, new production deployments should prefer AWS KMS: the private key is generated in and never leaves KMS, so it is never resident in the Guardian process. Set guardian_ack_ecdsa_kms_key_arn and the server uses the KMS backend instead of the Secrets Manager secret (Falcon is unaffected).

This is opt-in, not the default, because the KMS key is a distinct keypair: switching an existing deployment changes Guardian's ECDSA identity and requires the SwitchGuardian migration for existing accounts. Create the key and read the trade-offs in runbooks/secrets.md.

KMS covers ECDSA acks only. Falcon has no hosted signer, so a Falcon account is always acked by a key resident in the process. A KMS deployment therefore only realizes its custody benefit if new accounts are ECDSA, which is what the next section enforces.

Account signature scheme

Each account stores a signature scheme (Falcon or ECDSA) for each approver and for its GUARDIAN key; usually all of them share one scheme, chosen at creation. The GUARDIAN scheme selects which of this server's ACK keys signs the account's deltas. ECDSA is the scheme with hosted-signer support (the KMS backend above) and the default direction for Guardian; Falcon has no remote signer and is second-class. New production deployments should therefore accept only ECDSA registrations:

GUARDIAN_ALLOWED_ACCOUNT_SCHEMES=ecdsa      # Terraform: guardian_allowed_account_schemes

The gate acts on /configure for accounts that do not exist yet, returning signature_scheme_not_allowed (HTTP 403) with the rejected scheme and the accepted set in meta, and on a reconfiguration that adds a scheme the stored account does not use yet. Accounts already configured on this Guardian keep working under the schemes they use (the retry of a first /configure that failed before storing the account's state counts as new), because every later request is verified with the scheme stored for its signer, so the variable is safe to set on a fleet that already has Falcon accounts. An on-chain Falcon account that this Guardian does not know yet (a re-onboard after a metadata restore, or a SwitchGuardian from another Guardian) counts as new: widen the list to falcon,ecdsa for that migration and tighten it again afterwards. GET /dashboard/info reports accounts_by_auth_method if you want to see what exists first. The gate does not change which ACK keys the server needs: the Falcon ACK key is still loaded and still required today, so bootstrap and protect it as described above. Reference: CONFIGURATION.md.

Running behind your own ingress (non-AWS)

The rate limiter keys clients by IP, and that identity comes from the ingress in front of the server. The reference ALB deployment handles this automatically; if you run Guardian behind your own proxy or load balancer instead, these must hold:

  • Your ingress must append or overwrite X-Forwarded-For on both listeners: the HTTP port and the gRPC port. Guardian keys on the rightmost X-Forwarded-For entry, the one your ingress appended. Note that proxies often need separate configuration for gRPC (for example nginx grpc_pass does not add forwarding headers unless grpc_set_header is configured explicitly).
  • If your ingress identifies callers with X-Real-IP instead, it must strip any client-supplied X-Forwarded-For. X-Forwarded-For is read first, so a caller that sends one wins over the X-Real-IP your proxy set and picks its own rate-limit identity.
  • Only the ingress may reach the server ports (3000/50051). Forwarding headers are trusted whenever present, so a client that can connect directly can choose its own rate-limit identity.
  • If the ingress does not forward the client address at all (an unconfigured proxy, Kubernetes externalTrafficPolicy: Cluster SNAT, an L4 balancer without client-IP preservation), every client collapses into one shared budget keyed on the proxy's address: one noisy client then throttles everyone, and the sustained limit caps the whole deployment's throughput.

To check which case you are in, restart with RUST_LOG=info,server::middleware::rate_limit=debug (the per-rejection lines are debug, since refusals are expected traffic), trip the limiter and read the Request rate limited lines: client_ip must show real client addresses: not your proxy's address, not unknown, and not a value you forged in a test request. Two probes settle it: exhaust the budget from one machine and confirm a second machine on a different address still succeeds, then retry from the exhausted machine with a forged X-Forwarded-For prefix and confirm it stays throttled.

Production checklist

For a copy-pasteable, end-to-end walkthrough that satisfies every item below, follow the Production deployment guide. This checklist is the summary; the guide is the step-by-step.

Before treating a deployment as production-ready:

  • Set DEPLOY_STAGE=prod (AWS) or GUARDIAN_ENV=prod (anywhere else). The stage turns on the fail-fast guards and applies the production runtime defaults (rate limits, pool sizes, canonicalization concurrency, JSON logs) inside the server, so a self-managed deployment lists only what depends on its topology: GUARDIAN_MAX_REPLICAS, the cursor secret, metrics, and CORS. The production guide has the table.
  • Build with postgres, plus evm if the EVM API must be served.
  • Establish a stable ACK identity once. AWS: DEPLOY_STAGE=prod ./scripts/aws-deploy.sh bootstrap-ack-keys. Self-managed: GUARDIAN_ACK_SECRET_PROVIDER=file with two owner-only key files written by the image's ack-keygen --out-dir (runbooks/secrets.md).
  • For the ECDSA signer, decide between Secrets Manager (default) and KMS (preferred for new deployments where AWS is available); if using KMS, create the key and set guardian_ack_ecdsa_kms_key_arn per runbooks/secrets.md.
  • Restrict new accounts to ECDSA with GUARDIAN_ALLOWED_ACCOUNT_SCHEMES=ecdsa (see Account signature scheme). Safe to set even when Falcon accounts already exist; the Falcon ACK key stays required.
  • Confirm DATABASE_URL. AWS: supplied through the Terraform-managed RDS secret. Self-managed: points at your own Postgres with sslmode=verify-full&sslrootcert=… (see "Database TLS" in CONFIGURATION.md).
  • Optionally enable storage encryption at rest against an empty store (the Miden 0.17 reset is the natural window). AWS: run ./scripts/aws-deploy.sh bootstrap-storage-encryption-key, then deploy with GUARDIAN_STORAGE_ENCRYPTION_SECRET_NAME set. Self-managed: the same {active, keys} document in an owner-only file named by GUARDIAN_STORAGE_ENCRYPTION_KEY_FILE, rotatable the same way. See "Storage encryption" below.
  • Review database durability. AWS: the prod stage defaults to 7-day backup retention (point-in-time recovery), deletion protection on, and a final snapshot on destroy; Multi-AZ is opt-in via rds_multi_az. Self-managed: your database's backups and point-in-time recovery, with the encryption key kept alongside them. See "Durability and recovery" below.
  • Set GUARDIAN_CORS_ALLOWED_ORIGINS to the exact browser origins that need access.
  • If the operator dashboard is enabled, configure the operator allowlist secret and use object entries when permissions beyond dashboard:read are needed.
  • Pin GUARDIAN_DASHBOARD_CURSOR_SECRET identically on every replica. AWS: run ./scripts/aws-deploy.sh bootstrap-dashboard-cursor-secret before the first prod deploy; Terraform then injects the same value into every ECS task. Self-managed: one openssl rand -hex 32 value in every replica's environment.
  • Validate /, /pubkey, and the relevant SDK or dashboard smoke path after deploy.
  • Size the database and server tasks for the expected number of active session users before relying on the stage defaults (a 2 vCPU database, 2 vCPU tasks autoscaling to 6). Each 1,000 canonical nonce polls/s (about 2,000 users polling every 2 s) costs about 0.2 vCPU of database and 0.5 vCPU of server. With 20,000 polling users a 4 vCPU Graviton3 database ran at about 51% CPU; the server side at that load is not yet qualified (uneven per-task CPU, a slow write tail), so plan extra server tasks. Keep peak database CPU at or below about 70%. Table and caveats: SERVER_AWS_DEPLOY.md → Sizing for session reads; the per-vCPU figures apply to self-managed deployments too.
  • Size GUARDIAN_RATE_PER_MIN for the combined HTTP and gRPC volume: the sustained limit is keyed per IP alone, so gRPC traffic (the Rust SDK's and benchmark harness's default transport) draws on the same allowance as HTTP. Budgets sized for HTTP-only traffic under-provision after the transport-bypass fix. GUARDIAN_RATE_BURST_PER_SEC is keyed per IP and endpoint, so it applies to each HTTP path and gRPC method separately and can be sized per-endpoint rather than in aggregate.
  • On the first deploy that ships gRPC rate limiting, verify keying on the deployed gRPC path: against staging with a deliberately low guardian_rate_burst_per_sec, exhaust the budget from one machine, confirm a second machine on a different address is unaffected, then confirm a forged X-Forwarded-For prefix from the exhausted machine stays throttled. Owned by whoever runs the deploy.
  • On the AWS reference deployment, metrics are on by default: the endpoint binds loopback inside the ECS task and an ADOT sidecar exports selected metrics to CloudWatch dashboards and alarms — no external exposure, no bearer token needed. ERROR-level server log lines additionally feed a metric-filter alarm that does not depend on the metrics pipeline. See SERVER_AWS_DEPLOY.md and its log-level alarms section.
  • Route the alarms to a person. On AWS they notify nobody by default: set alarm_notifications_enabled with alarm_slack_workspace_id and alarm_slack_channel_id to deliver them to Slack through the managed <stack>-alarms SNS topic (the Slack workspace is authorized once per AWS account in the console), and/or list your own SNS topics in alarm_actions. Force a test alarm after the deploy and confirm both the ALARM and the OK message arrive (Alarm notifications). Self-managed deployments build alerting on their own metrics scraper.
  • Size the release sweep for your Miden node. It is on by default and spends up to GUARDIAN_RELEASE_SWEEP_MAX_RATE_PER_SECOND (default 5) account visits per second walking unreleased accounts, each at least one node read; lower it, or set GUARDIAN_RELEASE_SWEEP_ENABLED=false, if the node has no headroom (AWS: guardian_release_sweep_*). See CONFIGURATION.md.
  • Block watch (on by default) detects guardian switches from the node's committed blocks, within blocks of the switch, at a node cost that does not grow with the fleet: one BlockSubscription stream held by the release sweep's lease holder, or one GetBlockByNumber per block when polling. A public RPC endpoint serves 10 subscriptions per node instance to everyone and bans a subscriber that falls behind for 10 minutes; block watch then polls, but a dedicated node is the dependable setup. GUARDIAN_BLOCK_WATCH_TRANSPORT=poll never subscribes, GUARDIAN_BLOCK_WATCH_ENABLED=false turns it off (AWS: guardian_block_watch_*). Once it is healthy, the release sweep's walk is only a safety net: raise GUARDIAN_RELEASE_SWEEP_ROTATION_SECONDS (for example to a week) to cut its node traffic.
  • If you scrape Prometheus yourself in a self-managed deployment, set GUARDIAN_METRICS_ENABLED=true, bind an explicitly routable GUARDIAN_METRICS_ADDR only if the scraper lives outside the host or task, keep the port reachable only from the scraper's network, and set GUARDIAN_METRICS_BEARER_TOKEN. Note the AWS reference Terraform hard-binds the listener to 127.0.0.1 and exposes no bind-address, security-group, or token knobs — cloudwatch_metrics_enabled = false there leaves a loopback-only endpoint that only an in-task collector (added by customizing the module) can reach, not an external scraper. See the Observability guide for scraping and a Grafana dashboard stack, and CONFIGURATION.md for the env vars.

Durability and recovery

On the reference stack, all Guardian state — account state, deltas, proposals, account metadata, and audit rows — lives in RDS Postgres. The Guardian server itself is stateless, so crash resistance reduces to the database's guarantees:

  • Write durability. Postgres WAL: a write acknowledged by the database survives a crash of the instance. Guardian acknowledges a delta to the client only after the database write succeeds.
  • Point-in-time recovery. RDS automated backups (daily snapshot plus continuous WAL archiving) allow restore to any point within rds_backup_retention_days (default 7). WAL is shipped roughly every five minutes, which bounds worst-case data loss for a total instance loss to about that window.
  • Operator-error protection. In the prod stage, deletion protection is on and destroying the stack takes a final snapshot (<stack>-postgres-final) by default.
  • Standby failover. Multi-AZ is off by default in every stage. Set rds_multi_az = true if the deployment needs automatic failover to a standby replica; this is an availability trade-off (roughly double the instance cost), not a backup mechanism.
  • Guardian execution across a planned stop. On SIGTERM (what ECS and Docker send) the server refuses new executions with GUARDIAN_EXECUTION_BUSY, fails its attempts that have not reached the boundary commit with GUARDIAN_EXECUTION_ABANDONED (retryable, the proposal is kept), and waits up to 8 seconds for attempts past it to send, then exits. A deploy or scale-in therefore releases most of those accounts at once instead of after the 120-second lease. Three cases still leave an account to the lease and reconciliation: a kill that skips SIGTERM (OOM, SIGKILL); an attempt whose local transaction execution is already running on the CPU when the signal lands, which stops only at its next await, after the grace; and a send still waiting on the node when the 8 seconds run out. A send may wait up to 60 seconds (the slowest accepted devnet send took about 9), so a slow node at deploy time leaves its accounts held until reconciliation settles them from the chain. Nothing is sent twice either way.
  • Guardian execution across a crash (accepted risk). If the process dies after an execution's boundary commit (state submitted) and before the send has a definite outcome, the transaction may never have been sent. Reconciliation only observes the chain and never resends, so the account stays reserved (new executions get GUARDIAN_EXECUTION_CONFLICT, client deltas are refused) until the chain passes the transaction's expiration (at most 256 blocks after the reference block for built-in proposals; 20 for a fee-paying transaction on devnet, whose fee faucet caps it). It then settles as GUARDIAN_EXECUTION_EXPIRED, the proposal is deleted, and the cosigners must propose and sign again. The signal is guardian_execution_oldest_reservation_age_seconds climbing; the AWS reservation-age alarm (default 1800 s) is set above this window, so it fires only if the reservation outlives it. See TROUBLESHOOTING.md.
  • Guardian execution record retention. Every execution attempt leaves a reservation, possibly submission evidence, and an outcome. Once a day, starting a few minutes after startup, each replica deletes the finished attempts resolved more than GUARDIAN_EXECUTION_RECORD_RETENTION_DAYS (default 30) ago whose proposal is gone or that a newer attempt of the same proposal supersedes, in batches of 1,000 until a batch comes back short. Active attempts and the newest attempt of a proposal that still exists are never deleted, so attempt numbering continues and a client waiting on a live proposal still reads its outcome; a status read for a proposal whose records were deleted gets proposal_not_found, because only a deleted proposal loses its last record. The sweep is idempotent, so replicas need no coordination; each logs a summary at info and adds what it deleted to guardian_execution_records_pruned_total. Sizing: retained rows grow with executions per day times the retention (three small rows per attempt in Postgres, a few hundred bytes each), plus the newest attempt of every proposal still stored. 0 keeps records forever, the earlier behavior; budget storage for it accordingly.

What is deliberately not provided: cross-region replicas, automated disaster-recovery drills, or backup-failure alarms (see architecture/infra.md).

Two Guardian-specific caveats when restoring from a backup:

  • Restoring to an earlier point rewinds stored account state. Any delta that canonicalized on-chain after the restore point cannot be regenerated by the guardian — guarded accounts are private on Miden, so only client devices hold the full state. Affected accounts fail state-commitment verification until a device holding the newer state re-syncs it (see the failure table in CONCEPTS.md).
  • If storage encryption is enabled, database backups contain ciphertext. The storage-encryption key document is part of the recovery set whether it comes from Secrets Manager or from GUARDIAN_STORAGE_ENCRYPTION_KEY_FILE: losing it makes every restored payload unrecoverable. Keep a protected out-of-band copy alongside the database backups.

The verification and restore procedure is in runbooks/backup-restore.md.

Startup account recovery

Guardian can check its stored Miden account records against the Miden network when it starts, and bring a record back in line with the account's canonical history when the two disagree. GUARDIAN_STARTUP_ACCOUNT_RECOVERY selects the mode: off (the default), dry-run or apply. It needs a Guardian backed by Postgres. With the bundled Compose files, set it in .env.

Previewing with a dry run

Start Guardian once with GUARDIAN_STARTUP_ACCOUNT_RECOVERY=dry-run first. A dry run performs the same checks, logs what apply would do with each account, and writes nothing: no account record, no report row and no progress. It takes no lease, so it runs with any number of replicas, and it checks from the first account each time. It names each proposal a restore would change, and says so when apply would not run here (more than one replica, or the check already completed). The final log line counts the accounts that would be restored (restorable), deferred (retryable) and left unresolved (unresolved). A dry run stops after 5 minutes like apply; that line then shows stopped_early and how many accounts it did not reach (remaining).

Applying

  • Set GUARDIAN_STARTUP_ACCOUNT_RECOVERY=apply on a single Guardian instance.
  • Stop the old Guardian process before the new one starts. Rolling deployments overlap old and new servers even with a target of one instance, so do not use apply for those.
  • Guardian skips apply when GUARDIAN_MAX_REPLICAS exceeds 1.
  • On the AWS stack in infra/, set Terraform variable guardian_startup_account_recovery to "dry-run" or "apply" for that one deploy. It passes the mode to the task and lengthens the container health check start period and the load balancer grace period, so the task is not replaced while its listeners are closed. For apply, running a single task and keeping older tasks from running during the deploy remain manual steps. Terraform sets the task count and autoscaling, so make them through its variables: first apply server_autoscaling_enabled = false with server_desired_count = 0 and wait for the tasks to stop, then apply guardian_startup_account_recovery = "apply" with server_desired_count = 1. Leave guardian_max_replicas unset or at 1 for that deploy. Stopping a task or scaling the service outside Terraform is not enough, because the service or the next deploy starts a replacement. Once the check has completed, set the mode back to "off" and restore the usual task count and autoscaling.

What it does

The check runs before the API listeners open. For each account whose stored record differs from its latest canonical delta, Guardian asks the configured Miden node for the account's current commitment. It covers accounts recorded for the configured network and accounts recorded as local or devnet, which is how an account registered without a network is stored.

  • If the stored record already matches the network, nothing changes.
  • If the configured node has no record of the account and Guardian holds no canonical deltas for it, the stored record stands only when it is the account's first state. Any other record is listed as unresolved.
  • If the network is past the canonical deltas Guardian holds and no delta in flight ends at the network's state, the account is listed as unresolved. If the configured node reports an earlier state of the account, the account is deferred.
  • If Guardian holds the account's canonical deltas from creation, it rebuilds the account from them. An account whose history takes more than a minute to rebuild is listed as unresolved. When the result matches the network and is bound to this server's ACK key, Guardian stores it together with its nonce and the account metadata derived from it. The same transaction saves the previous record in account_recovery_backups; encrypted state keeps its original ciphertext.
  • Otherwise the account is left unchanged and listed in account_recovery_pending.

A restore also reviews the account's pending proposals against the signers of the restored state. A proposal that one of those signers proposed or approved stays, keeping only their approvals. Any other pending proposal is removed, except one whose transaction summary cannot be read, which stays as it is. Every proposal a restore changes or removes is saved with the previous record in account_recovery_backups.prior_proposals. If the account's proposals cannot be read, the restore leaves them as they are.

An account with work in flight (a delta awaiting its on-chain outcome or a reserved execution) is deferred and checked again on a later startup. Work counts when it starts from the account's latest canonical state, or when it is a delta that ends at the network's current state. A paused account is checked like any other, and stays paused.

How long it takes

  • Guardian checks accounts for up to 5 minutes and lets a write in progress finish. The listeners can stay closed for about 6 minutes: the 5-minute budget, up to 35 seconds waiting for the recovery lease, and the final writes. Allow for that in any startup health check or grace period.
  • The check stops for this startup after three account checks in a row fail, for example while the Miden node is unreachable.
  • In apply, Guardian records where it stopped in account_recovery_startup.resume_after, and the next startup in apply continues from there.
  • The check completes when a pass reaches the last account without deferring any. A pass can span several startups: one that stops early keeps its position and its counts. A pass that deferred an account is followed by a new pass from the first account. On completion Guardian records how many accounts it could not bring up to date in account_recovery_startup.unresolved_accounts, and later startups skip the check. Until then, each startup in apply runs it again.
  • An account Guardian holds canonical deltas for, but the configured node has no record of, is deferred. It keeps the check open until the node knows the account or the account is released.

If it cannot run

In apply, Guardian exits before opening its listeners if another process holds the recovery lease, or if it cannot confirm it holds the lease alone. It first waits up to 35 seconds for a lease a stopped process left behind. Any other error, and any error in a dry run, is logged, and Guardian opens its listeners without finishing the check.

Reviewing the result

After apply, account_recovery_pending has one row for each account that was checked and not brought up to date. outcome is deferred (a later startup checks it again) or unresolved (Guardian does not hold what it needs), and reason says why. When the canonical history held here does not reach back to the account's creation, history_starts_at_nonce and history_base_commitment show where it begins.

An unresolved account the network has a record of is brought up to date the next time it is registered with its current state. One the network has no record of cannot be registered again while its stored state remains. Remove that row with the statement below and keep its output, which is the removed row. It removes the row only while it still holds the stored_commitment listed for the account in account_recovery_pending. The account's next registration with its first state is then accepted:

DELETE FROM states
WHERE account_id = '<account id>' AND commitment = '<stored_commitment>'
RETURNING to_jsonb(states);

A row is removed once its account is brought up to date or found unchanged. A row whose stored_commitment no longer matches the account's stored state is out of date. Export the current list with:

SELECT jsonb_agg(to_jsonb(p) ORDER BY p.account_id)
FROM account_recovery_pending p
JOIN states st ON st.account_id = p.account_id
              AND st.commitment = p.stored_commitment;

To put back the record a restore replaced, use its row in account_recovery_backups. The first statement changes the state only while the account still holds the restored commitment:

BEGIN;
UPDATE states st
SET state_json = b.prior_state->'state_json',
    commitment = b.prior_state->>'commitment',
    nonce = (b.prior_state->>'nonce')::bigint,
    updated_at = now()
FROM account_recovery_backups b
WHERE b.id = <backup id> AND st.account_id = b.account_id
  AND st.commitment = b.recovered_commitment;
UPDATE account_metadata m SET auth = b.prior_auth, updated_at = now()
FROM account_recovery_backups b
WHERE b.id = <backup id> AND m.account_id = b.account_id;
INSERT INTO delta_proposals
SELECT p.* FROM account_recovery_backups b,
     jsonb_populate_recordset(NULL::delta_proposals, b.prior_proposals) p
WHERE b.id = <backup id>
ON CONFLICT (account_id, commitment) DO UPDATE
    SET status = EXCLUDED.status, status_kind = EXCLUDED.status_kind,
        status_timestamp = EXCLUDED.status_timestamp,
        delta_payload = EXCLUDED.delta_payload;
COMMIT;

To run the check again after it completed, remove its completion record and restart Guardian:

DELETE FROM account_recovery_startup
WHERE network_config->>'network_type' = '<configured network>';

Storage encryption

Guardian can encrypt the sensitive stored payloads (account state, delta and proposal payloads, and each delta's dashboard metadata) at rest, above whatever disk-level encryption the database already provides. It is opt-in: set a key source and the server encrypts; set none and behavior is unchanged.

  • Confidentiality boundary: only the payload JSON is encrypted — the account state_json, delta delta_payload and metadata, and proposal delta_payload. Routing and index columns (account_id, nonce, status, state and proposal commitment) stay plaintext by design: they are needed for lookups and some are bound as AEAD additional authenticated data (authenticated, not hidden). That includes the stored state's nonce, kept next to its commitment so the canonical-nonce pre-check never decrypts the state; it reveals the account's transaction count. "Encrypted at rest" here means payload confidentiality, not metadata confidentiality — anyone with database read access still sees which accounts exist, their nonce/commitment lineage, and proposal status. Use disk/database-level encryption if the index metadata itself is sensitive in your threat model.

  • Guardian execution records are plaintext too. In Postgres that is every column of execution_reservations, execution_submissions and execution_outcomes (proposal ids, transaction ids, expected and base commitments, reference and expiration blocks, ignored signature counts, error_code, error_message, error_meta) and delta_proposals.request_bytes; on the filesystem backend, each account's executions.json and proposal_request_bytes.json. The stored transaction request itself sits inside the proposal delta_payload and is encrypted with it.

  • Production key source: the key document { "active": "k1", "keys": { "k1": "<base64 32 bytes>" } }, held either in AWS Secrets Manager or in an owner-only file. On the standard stack, ./scripts/aws-deploy.sh bootstrap-storage-encryption-key creates the secret and a deploy with GUARDIAN_STORAGE_ENCRYPTION_SECRET_NAME set wires GUARDIAN_STORAGE_ENCRYPTION_KEY_SECRET_ID plus the task-role secretsmanager:GetSecretValue grant (same pattern as the ACK keys); AWS_REGION is reused. Self-managed deployments mount the same document and set GUARDIAN_STORAGE_ENCRYPTION_KEY_FILE (production guide, track B).

  • Enable against an empty store. The server writes a one-time marker on the first encrypted write and then refuses to mix plaintext and ciphertext, so it fails fast if a key is configured against a store that already holds plaintext records. For Miden-only deployments the Miden 0.17 reset (which purges Miden account data) is the natural enablement window; deployments that also retain EVM account rows — which the reset preserves — must clear or migrate those plaintext records before enabling encryption, or the first encrypted write will fail fast against the mixed store.

  • Startup is fail-fast: a missing/malformed/wrong-length key, or more than one key source, prevents startup rather than degrading to plaintext.

  • Key rotation, on either source: add a new entry to keys and move active; keep the old key so existing records still decrypt. Bulk re-encryption tooling is not yet provided.

Full configuration and a dev walkthrough are in CONFIGURATION.md.

Upgrading to Miden 0.17

One-time, irreversible: the first 0.17 deploy wipes all pre-0.17 Miden account data. EVM accounts are unaffected. Stored 0.16 Miden states, deltas, proposals, and metadata can no longer be deserialized or recomputed, and cannot be migrated. For what changed on the Miden side and why none of it survives, see MIDEN_COMPATIBILITY.md. Guardian 0.18.x is the release that adopts Miden 0.17; Guardian 0.17.x runs on Miden 0.16. Upgrade only once the network you serve runs a stable Miden 0.17 node (0.17.0 or later): which public networks do, and the upstream items still open, are tracked in MIDEN_COMPATIBILITY.md.

What happens on the first 0.17 startup (Postgres backend):

  • The embedded reset migration 2026-09-22-000001_miden_017_irreversible_reset runs automatically via run_pending_migrations. Its scope, locking, and preserved tables are those of the 0.16 reset below; the dashboard stats snapshot is preserved as well.
  • A deployment upgrading across more than one line also runs the older resets in the same startup; this one subsumes them.
  • The additive migrations 2026-09-15-000001_dashboard_stats_snapshot and 2026-09-30-000001_state_nonce run in the same startup. The second adds the plaintext nonce column the canonical-nonce endpoint reads (see "Storage encryption" above).

Operator actions are the 0.16 list below, with the Miden 0.17 node in step 3, plus:

  • Deploy the server before the SDKs. The 0.18.x SDKs ask GUARDIAN for the canonical nonce (GET /state/nonce, gRPC GetCanonicalNonce) before every sync and fail against a server that does not serve it.
  • Client stores must be recreated, not just cleared: a Rust SQLite store or a browser IndexedDB store created under 0.16 does not open under 0.17.
  • Recreated accounts must hold the chain's native fee asset. On Miden 0.17 the guarded-multisig auth procedure pays the transaction fee from the account's vault, including on the transaction that deploys the account, so an unfunded account cannot transact. Fund each account before its first proposal (on devnet, through the node's RegisterAccount RPC; see MIDEN_COMPATIBILITY.md).
  • Review the defaults that are new in 0.18.x: GUARDIAN_ENV=prod now applies the production runtime defaults inside the server, the release sweep runs by default, and GUARDIAN_ALLOWED_ACCOUNT_SCHEMES is available. The reset deletes account_metadata, so every Falcon account registered before the upgrade counts as new afterwards and an ecdsa-only gate rejects it. Set ecdsa only when those accounts will be recreated as ECDSA; otherwise keep falcon,ecdsa until they have re-registered (see Account signature scheme). AWS deployments apply the release's Terraform, which adds the alarm notification, release sweep, and account-scheme variables, before rolling the image.

Upgrading within the Miden 0.17 line

Releases after 0.18.0 on the Miden 0.17 line (0.18.x patches and 0.19.x) keep stored data, the auth_tx procedure root, and existing accounts; no reset runs. From 0.19.0 the server itself builds on Miden 0.18 and needs a node on 0.18; accounts keep the same contract code, which is why that release is listed here. Each one still has operator-visible changes. The SDK and Miden-side ones are in MIDEN_COMPATIBILITY.md, and each release's notes on GitHub carry the full list, including server behavior:

  • 0.18.1 requires the new image: deploy the server first, then the SDKs (release notes). It adds Miden account sessions (#537), which only work against a 0.18.1 server and bring the optional GUARDIAN_SESSION_MAX_TTL_SECONDS and the error codes 401 session_expired, 401 session_revoked and 403 wallet_signature_required. It verifies proposal approvals against the transaction summary (#526): a client that posts another cosigner's approval at proposal creation, or an approval that does not verify, gets 400 invalid_proposal_signature. The repository's SDKs comply; watch for that code from custom or third-party clients after the rollout. It also adds the opt-in candidate queue (#486), moves to the Miden 0.17 patch pins and replaces the proposal chain_anchor with bound_block_num. 0.18.0 SDKs cannot sign or execute proposals that 0.18.1 SDKs create, so upgrade every party that signs or executes an account's proposals together. It is also the TypeScript SDK floor for raising GUARDIAN_MAX_PENDING_CANDIDATES_PER_ACCOUNT above 1 (CONFIGURATION.md).
  • 0.18.2 adds the MidenCedar and MidenMainnet network types. Deploy the server before configuring clients for either: older servers reject the labels with unsupported Miden network_type. /pubkey without scheme returns the Falcon key even on an ECDSA-only server, so health checks and integrations that want the ECDSA commitment must pass ?scheme=ecdsa.
  • 0.18.3 rebuilds the server image against Debian ca-certificates 20250419~deb12u2, which distrusts the compromised eMudhra intermediates. The server trusts the system store for Miden RPC and AWS, so redeploy the new image; restarting a container from an older image keeps the old trust store. No data reset, and no SDK upgrade is needed (release notes).
  • 0.19.0 gates multisig pushes on stored approvals, lets sessions sign delta pushes, registers only guarded multisig accounts, and adds the retryable 409 state_not_on_chain for reconfigurations that must use the chain's state (a first registration of an account that already transacted, a released account, a key the stored auth does not list, or a state other than the stored one). After a GUARDIAN switch the new SDKs wait for the chain to hold the switched state before they register, and register once; older SDKs fail a switch to a GUARDIAN on this release until the user registers again. Release the SDKs first: multisig pushes need them, and on an older server the new SDKs sign a refused session push again with the wallet; see MIDEN_COMPATIBILITY.md. One exception to SDKs-first: a new SDK's abandon_candidate / abandonCandidate sends proposal_id, which a server up to 0.18.3 refuses as unauthenticated, so abandons fail until the server is upgraded. The release also brings:
    • A Miden 0.18 node. The server and the Rust SDK build on Miden 0.18.0 and use the node 0.18 RPC, so move the Miden node the server reads to 0.18 before deploying this image; the server does not work against a 0.17 node. Node 0.18 still serves 0.17 clients, so SDKs from earlier releases and the TypeScript SDK (web SDK 0.17.8) keep working against it, and stored data and accounts carry over. Plan for three things. Rust SDK clients must recreate their local store, and should keep a copy of the old one, because unconsumed private notes live only there. A Guardian-executable custom proposal that declares a public foreign account and is still pending at the upgrade can no longer be executed by GUARDIAN: have GUARDIAN execute it before upgrading, or execute it afterwards from an SDK on the Miden line that created it. And, as a second exception to SDKs-first, a server before 0.19.0 does not execute the Guardian-executable proposals Rust clients on this release create, until it is upgraded (see MIDEN_COMPATIBILITY.md).
    • Guardian execution, enabled in two deploys. An older replica still running during a rolling update can leave an executing account reserved with nothing able to release it. Roll out 0.19.0 with GUARDIAN_TX_PROVER_URL unset, then set it in a second deploy once no older replica runs. To roll back, set GUARDIAN_PROVING_ENABLED=false first, wait until guardian_execution_oldest_reservation_age_seconds reads 0 (no active execution), and only then deploy the older image (see MIDEN_COMPATIBILITY.md). On AWS, the Deploy AWS workflow (aws-deploy.yml) only swaps the image: turning execution on, and creating its alarms, needs a Terraform apply of this release's infra/ with guardian_tx_prover_url (or guardian_tx_prover_url_secret_arn) set.
    • Mixed-scheme accounts (Falcon and ECDSA cosigners), with no rollback once one is stored. Servers up to 0.18.3 cannot read the stored Miden auth, so finish the server rollout before clients register mixed accounts, and do not roll back to 0.18.x afterwards: older replicas fail every request for such an account, and a filesystem metadata store fails to load as a whole (see MIDEN_COMPATIBILITY.md).
    • Operation-bound session requests (session-v2), with no fallback. The server accepts session requests only in the version 2 format, and earlier releases, 0.19.0-rc.1 included, only in version 1. Older SDKs lose session requests against it (unsupported_auth_version), and the new SDKs refuse to start a session against an older server; wallet-signed requests work throughout. Keep the time both server versions run short (see MIDEN_COMPATIBILITY.md, and for AWS SERVER_AWS_DEPLOY.md).
    • Delta and proposal nonces checked at every queue depth (#518). A delta must be labelled with the account nonce it leaves the account at, and a proposal with the account's next nonce. Any other label gets 400 invalid_delta, except one at or below the newest queued candidate's nonce, which still gets 409 conflict_pending_delta. Both SDKs label that way by default, the TypeScript SDK since 0.18.1; cosigners on TypeScript 0.18.0 or earlier can no longer create proposals, and a pending proposal labelled with a timestamp has to be created again (see MIDEN_COMPATIBILITY.md).
    • Block watch, on by default. The release sweep's lease holder follows the node's committed blocks to detect guardian switches; check the node it reads from against the production checklist before the rollout.

Upgrading to Miden 0.16

One-time, irreversible: the first 0.16 deploy wipes all pre-0.16 Miden account data. EVM accounts are unaffected. Stored 0.15 Miden states, deltas, proposals, and metadata can no longer be deserialized or recomputed, and cannot be migrated. For what changed on the Miden side and why none of it survives, see MIDEN_COMPATIBILITY.md. Guardian 0.17.x is the release that adopts Miden 0.16; Guardian 0.16.x runs on Miden 0.15.

What happens on the first 0.16 startup (Postgres backend):

  • The embedded reset migration 2026-08-24-000001_miden_016_irreversible_reset runs automatically via run_pending_migrations and deletes Miden-network rows from delta_proposals, deltas, states, and account_metadata. Rows whose account_metadata.network_config->>'kind' is evm are preserved across all four tables. Every other row is purged, including Miden rows and any row orphaned from its metadata.
  • account_auth_state is cleared by cascade from account_metadata, so per-signer replay floors for deleted accounts go with them.
  • The migration takes a brief ACCESS EXCLUSIVE lock on account_metadata so a replica still running the old binary cannot write Miden rows mid-reset. It fails fast (5s lock_timeout) rather than stalling startup; if that happens, confirm the old server is stopped and restart.
  • Preserved: admin_actions (append-only audit), auth_sessions, auth_challenges, storage_encryption_marker, worker_leases, and the Guardian ACK/operator keystore. Guardian identity and operational audit data survive the reset.
  • The migration is irreversible: its down.sql is a no-op. There is no partial-salvage path and no legacy-account filtering: every incompatible surface is removed at once rather than left for per-instance repair.
  • A deployment upgrading from before 0.15 also runs the older 2026-06-14-000001_v015_account_id_cutover in the same startup. Its effect is subsumed by this reset (both purge Miden rows and preserve EVM rows), so the steps below are the only ones that apply.

Operator actions, in order:

  1. Back up the database. This is the only way to retain pre-0.16 records, and the reset runs automatically on startup. Do this even if you believe the data is disposable: for private accounts, Guardian may hold state the client no longer has, and step 4 clears the client copy too.
  2. Stop the old server before deploying. The lock above is a backstop, not a substitute.
  3. Deploy against a matching Miden 0.16 node. A 0.16 server against a 0.15 node fails on protocol mismatch, not on anything this reset controls.
  4. Clear client-side state: SDK SQLite stores, browser IndexedDB, and local metadata under ~/.guardian. Stale local metadata outlives the server reset and will not deserialize.
  5. Recreate and re-register accounts. There is no in-place account migration; users re-establish custody accounts and register them on the Guardian. EVM accounts continue operating unchanged.
  6. Discard all pending and offline proposals. Exported proposal files and unexecuted pending proposals from 0.15 are bound to the old summary layout and procedure roots, so they can never execute.

Filesystem-backed deployments have no migration step: start from empty storage and metadata directories, and preserve the keystore directory.

Where details live

Need Read
End-to-end production walkthrough (AWS ECS, self-managed Docker, Docker + AWS secrets) guides/production/
Match a Guardian release to a Miden version MIDEN_COMPATIBILITY.md
Step-by-step setup for a specific run mode guides/
Deploy or update the AWS stack SERVER_AWS_DEPLOY.md
Size the database and server tasks for a read load SERVER_AWS_DEPLOY.md → Sizing for session reads
Route CloudWatch alarms to Slack or SNS SERVER_AWS_DEPLOY.md → Alarm notifications
Set up the IAM roles behind the AWS Deploy workflow runbooks/github-oidc-deploy-roles.md
Understand the AWS topology and Terraform ownership architecture/infra.md
Understand server storage modes and why prod uses Postgres architecture/services.md
Check runtime and deploy-time env vars CONFIGURATION.md
Bootstrap, replace, or respond to ACK/operator/EVM secret issues runbooks/secrets.md
Verify database backups or restore from one runbooks/backup-restore.md
Migrate a deployed stack to verified database TLS runbooks/enable-db-tls.md
Configure dashboard operators and permissions DASHBOARD.md
Scrape Prometheus metrics and visualize them guides/observability/
Diagnose deploy/runtime failures TROUBLESHOOTING.md

Non-goals

This page does not replace the AWS deploy guide or the runbooks. Keep procedural steps in those docs so deployment behavior has one source of truth.