{"record":{"id":"3df1a3143f395730","repo":"nautechsystems/nautilus_trader","slug":"verification-migration-was-supplied-for-an-initial","errorCode":null,"errorMessage":"Verification migration was supplied for an initialized signer","messagePattern":"Verification migration was supplied for an initialized signer","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":4023,"sourceCode":"        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            );\n\n            if observed_canonical_nonce != stored_nonce {\n                let expected_observed_nonce = stored_nonce\n                    .checked_add(1)\n                    .ok_or_else(|| anyhow::anyhow!(\"Canonical nonce overflow\"))?;\n                anyhow::ensure!(","sourceCodeStart":4005,"sourceCodeEnd":4041,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L4005-L4041","documentation":"The nonce ledger already has an initialized row for this (chain_id, wallet_address), meaning the signer has been bootstrapped before. A migration payload in the bootstrap request would re-initialize or transform signer state, which is only legal for a fresh/uninitialized signer, so the code rejects it to protect the existing durable nonce history.","triggerScenarios":"Calling the verification bootstrap with bootstrap.migration = Some(..) for a chain_id/wallet_address whose execution_verification_nonce row already exists.","commonSituations":"Re-running an initial-setup script (that includes a migration parameter) against an already-initialized signer; copy-pasting a bootstrap config from a new wallet to an existing one; pointing a migration job at production after it ran in staging with the same wallet.","solutions":["Remove the migration parameter from the bootstrap request for this wallet — it is already initialized","Use a fresh wallet_address if a migration-backed initialization is truly intended","Verify chain_id/wallet_address match the intended signer; a typo can make an initialized signer appear at the wrong key","If state is genuinely corrupted, follow the project's documented recovery procedure rather than re-migrating"],"exampleFix":"// before\nlet bootstrap = Bootstrap { manifest_version, manifest_digest, migration: Some(mig), .. };\n// after (wallet already initialized)\nlet bootstrap = Bootstrap { manifest_version, manifest_digest, migration: None, .. };","handlingStrategy":"validation","validationCode":"// Only include a migration when the signer row is absent\nlet initialized = sqlx::query_scalar::<_, i32>(\n  \"SELECT 1 FROM execution_verification_nonce\n   WHERE chain_id=$1 AND wallet_address=$2\")\n  .bind(chain_id).bind(wallet)\n  .fetch_optional(&mut *conn).await?.is_some();\nlet migration_opt = if initialized { None } else { Some(migration) };","typeGuard":null,"tryCatchPattern":"match bootstrap_signer(req).await {\n    Err(e) if e.to_string().contains(\"Verification migration was supplied for an initialized signer\") => {\n        warn!(wallet = %req.wallet, \"already initialized; dropping migration and retrying\");\n        bootstrap_signer(Bootstrap { migration: None, ..req }).await\n    }\n    other => other,\n}","preventionTips":["Treat bootstrap-with-migration as a one-time, fresh-wallet-only operation","Keep a registry of initialized (chain_id, wallet) pairs before running setup scripts","Validate wallet_address/chain_id inputs to avoid typos hitting the wrong signer row","Never reuse an initialization script against production after staging runs with the same wallet"],"tags":["database","state","signer","invalid-argument","nonce"],"backgroundTag":"invalid-state-transition","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"}