{"record":{"id":"65594088a832b047","repo":"nautechsystems/nautilus_trader","slug":"verified-finalized-transaction-count-advanced-with","errorCode":null,"errorMessage":"Verified finalized transaction count advanced without an active owned intent","messagePattern":"Verified finalized transaction count advanced without an active owned intent","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":4074,"sourceCode":"                                  'broadcast', 'included', 'replaced', 'dropped', 'reorged'\n                              )\n                        )\n                    FROM execution_intent AS intent\n                    LEFT JOIN execution_transaction_hash AS hash\n                        ON hash.intent_id = intent.id\n                    WHERE intent.chain_id = $1\n                      AND intent.wallet_address = $2\n                      AND intent.active\n                    GROUP BY intent.id, intent.nonce, intent.status\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 validate nonce recovery ownership: {e}\"))?;\n                let Some((intent_nonce, intent_status, payload_count)) = recovery else {\n                    anyhow::bail!(\n                        \"Verified finalized transaction count advanced without an active owned intent\"\n                    );\n                };\n                anyhow::ensure!(\n                    intent_nonce == Some(stored_nonce)\n                        && matches!(\n                            intent_status.as_str(),\n                            \"broadcast\" | \"included\" | \"replaced\" | \"dropped\" | \"reorged\"\n                        )\n                        && payload_count == 1,\n                    \"Verified finalized transaction count advanced without one recoverable retained payload at the durable nonce\"\n                );\n            }\n            revision\n        } else {\n            anyhow::ensure!(\n                next_canonical_nonce == observed_canonical_nonce,\n                \"Initial canonical nonce conflicts with the verified finalized transaction count\"","sourceCodeStart":4056,"sourceCodeEnd":4092,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L4056-L4092","documentation":"During execution-verification bootstrap the node observed an on-chain finalized transaction count one higher than the durable canonical nonce ledger. The nonce-recovery path therefore requires an active execution intent at exactly the stored nonce with one retained recoverable payload, but the ownership query returned no rows. This guard prevents silently advancing the signed-transaction nonce ledger without a matching owned in-flight intent.","triggerScenarios":"Running verification bootstrap (start/execute nonce-recovery check) when observed_canonical_nonce == stored_nonce + 1 but the execution_intent table has no row with chain_id, wallet_address matching the bootstrap signer and active = true — e.g. the intent was deactivated/deleted, the wrong wallet_address is in the bootstrap, or recovery bookkeeping was wiped.","commonSituations":"Operator restored a database dump that excluded execution_intent rows while finalized-header data survived; bootstrap configured against a different wallet than the one that signed the pending transaction; a prior recovery was manually cleaned up while finalized nonce state was kept; running against a fresh/stale environment with mismatched chain_id.","solutions":["Verify the bootstrap wallet_address matches the wallet of the in-flight (broadcast) transaction and that chain_id is correct","Restore the execution_intent row (and its execution_transaction_hash payload) for the stored nonce from backup, or re-create the recovery intent for that nonce","If the finalized transaction is genuinely not owned, roll back observed finalized-header state so observed_canonical_nonce equals the stored ledger nonce and re-bootstrap","Check that no cleanup job or migration deactivated the intent prematurely; re-activate it and retry"],"exampleFix":"// before: bootstrap against wrong wallet, intent not owned\nExecutionVerificationBootstrap { wallet_address: \"0xAAA...\", .. }\n// after: use the wallet that owns the broadcast intent at the stored nonce\nExecutionVerificationBootstrap { wallet_address: signer_wallet.address(), .. }","handlingStrategy":"validation","validationCode":"let recovery = sqlx::query_as::<_, (Option<i64>, String, i64)>(\n    \"SELECT intent.nonce, intent.status, COUNT(hash.id) \\\n     FROM execution_intent intent LEFT JOIN execution_transaction_hash hash ON hash.intent_id = intent.id \\\n     WHERE intent.chain_id = $1 AND intent.wallet_address = $2 AND intent.active GROUP BY intent.id, intent.nonce, intent.status\")\n    .bind(chain_id).bind(&wallet_address).fetch_optional(&mut *tx).await?;\nif recovery.is_none() && observed_nonce > stored_nonce {\n    return Err(anyhow!(\"no active intent to cover finalized nonce advance\"));\n}","typeGuard":"fn has_active_recovery(r: &Option<(Option<i64>, String, i64)>) -> bool {\n    matches!(r, Some((Some(_), s, 1)) if matches!(s.as_str(), \"broadcast\"|\"included\"|\"replaced\"|\"dropped\"|\"reorged\"))\n}","tryCatchPattern":"match bootstrap_verification(...).await {\n    Err(e) if e.to_string().contains(\"without an active owned intent\") => {\n        // inspect execution_intent for the wallet, restore or reconcile before retrying\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Keep execution_intent and execution_transaction_hash rows retained until the canonical nonce ledger has been reconciled","Always bootstrap with the exact wallet_address that owns the in-flight intent","Include execution_intent tables in database backups and restores","Disable intent cleanup jobs during verification bootstrap"],"tags":["rust","blockchain","database","nonce","consistency"],"backgroundTag":"internal-invariant-violation","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"}