{"record":{"id":"17806826059df4a8","repo":"nautechsystems/nautilus_trader","slug":"failed-to-read-canonical-nonce-ledger-e","errorCode":null,"errorMessage":"Failed to read canonical nonce ledger: {e}","messagePattern":"Failed to read canonical nonce ledger: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":4017,"sourceCode":"            anyhow::ensure!(\n                installed_version <= VERIFICATION_SCHEMA_VERSION,\n                \"Execution verification schema version {installed_version} is newer than supported version {VERIFICATION_SCHEMA_VERSION}\"\n            );\n        }\n\n        let current = sqlx::query_as::<_, (String, String, i64, i64)>(\n            \"\n            SELECT manifest_version, manifest_digest, next_canonical_nonce, revision\n            FROM execution_verification_nonce\n            WHERE chain_id = $1 AND wallet_address = $2\n            FOR UPDATE\n            \",\n        )\n        .bind(chain_id)\n        .bind(bootstrap.wallet_address)\n        .fetch_optional(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to read canonical nonce ledger: {e}\"))?;\n        let initialized = current.is_some();\n\n        let revision = if let Some((manifest_version, manifest_digest, stored_nonce, revision)) =\n            current\n        {\n            anyhow::ensure!(\n                bootstrap.migration.is_none(),\n                \"Verification migration was supplied for an initialized signer\"\n            );\n            anyhow::ensure!(\n                manifest_version == bootstrap.manifest_version\n                    && manifest_digest == bootstrap.manifest_digest,\n                \"Execution verification manifest identity changed\"\n            );\n            anyhow::ensure!(\n                stored_nonce == next_canonical_nonce,\n                \"Canonical nonce ledger changed during verification bootstrap\"\n            );","sourceCodeStart":3999,"sourceCodeEnd":4035,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L3999-L4035","documentation":"Bootstrap reads the durable canonical nonce ledger row (manifest_version, manifest_digest, next_canonical_nonce, revision) for (chain_id, wallet_address) from execution_verification_nonce. Any database failure of this SELECT is wrapped in this error; it is distinct from the row simply not existing (which means the signer is uninitialized).","triggerScenarios":"The SELECT ... FROM execution_verification_nonce WHERE chain_id=$1 AND wallet_address=$2 FOR UPDATE fails: table missing, connection error, permissions, or transient Postgres failure during the locked bootstrap transaction.","commonSituations":"Verification schema never installed on this database; DB credentials/grants changed; transient connection drop during startup; querying with a database URL pointing at the wrong environment.","solutions":["Ensure the execution_verification_nonce table exists (run the schema install step)","Check grants for the connecting DB role on execution_verification_nonce","Retry after transient connection failures","Confirm the database URL/environment is the intended one"],"exampleFix":"// before: wrong env DB\nDATABASE_URL=postgres://staging-db/nautilus\n// after: correct env\nDATABASE_URL=postgres://prod-db/nautilus\n","handlingStrategy":"validation","validationCode":"let exists: Option<i16> = sqlx::query_scalar(\n  \"SELECT 1 FROM information_schema.tables\n   WHERE table_name='execution_verification_nonce'\")\n  .fetch_optional(&mut *conn).await?;\nif exists.is_none() { install_verification_schema(&mut conn).await?; }\nlet has_select = sqlx::query_scalar::<_, bool>(\n  \"SELECT has_table_privilege(current_user,'execution_verification_nonce','SELECT')\")\n  .fetch_one(&mut *conn).await?;\nanyhow::ensure!(has_select, \"app role lacks SELECT on execution_verification_nonce\");","typeGuard":null,"tryCatchPattern":"match read_nonce_ledger(&mut tx, chain_id, wallet).await {\n    Err(e) if is_transient_db_error(&e) => retry_with_backoff(3, || read_nonce_ledger(&mut tx, chain_id, wallet)),\n    Err(e) => return Err(e),\n    Ok(row) => row,\n}","preventionTips":["Verify the verification schema is installed before bootstrap","Confirm DB role grants on all execution_verification_* tables","Double-check DATABASE_URL points at the intended environment","Retry transient DB errors instead of crashing the bootstrap"],"tags":["database","postgres","sql","nonce"],"backgroundTag":"sql-query-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}