{"record":{"id":"34c135f86dbfc5be","repo":"nautechsystems/nautilus_trader","slug":"execution-payload-storage-is-not-rewrapping","errorCode":null,"errorMessage":"Execution payload storage is not rewrapping","messagePattern":"Execution payload storage is not rewrapping","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":5431,"sourceCode":"        lock_execution_payload_operation(&mut transaction).await?;\n        let state_row = sqlx::query(\n            \"SELECT deployment_id, protocol_version, operation, active_key_id \\\n             FROM execution_payload_state WHERE component = 'signed_transactions' FOR UPDATE\",\n        )\n        .fetch_optional(&mut *transaction)\n        .await\n        .context(\"failed to lock execution payload rewrap state\")?\n        .ok_or_else(|| anyhow::anyhow!(\"Execution payload rewrap state is missing\"))?;\n        let state = execution_payload_state_from_row(&state_row)?;\n        validate_execution_payload_state(&state, keys)?;\n        if state.operation == \"ready\" {\n            transaction\n                .commit()\n                .await\n                .context(\"failed to complete execution payload rewrap\")?;\n            return Ok(true);\n        }\n        anyhow::ensure!(\n            state.operation == \"rewrap\",\n            \"Execution payload storage is not rewrapping\"\n        );\n        let rows = sqlx::query_as::<_, ExecutionTransactionHashRow>(\n            \"\n            SELECT\n                id, intent_id, chain_id, transaction_hash, payload_expected,\n                raw_transaction, sealed_transaction, status, block_number, block_hash,\n                receipt_success, gas_used, effective_gas_price, current\n            FROM execution_transaction_hash\n            WHERE payload_expected\n              AND substring(sealed_transaction FROM 2 FOR 32) <> $1\n            ORDER BY id\n            LIMIT $2\n            FOR UPDATE\n            \",\n        )\n        .bind(keys.active_key_id().as_slice())","sourceCodeStart":5413,"sourceCodeEnd":5449,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L5413-L5449","documentation":"After locking the `execution_payload_state` row, `rewrap_execution_payload_batch` treats operation 'ready' as 'nothing to do' and otherwise requires the operation to be exactly 'rewrap'. This `anyhow::ensure!` fires when the stored operation is neither 'ready' nor 'rewrap', meaning the payload storage is in some other maintenance mode and cannot be safely batch-rewrapped.","triggerScenarios":"A concurrent or previous rewrap/maintenance operation left `execution_payload_state.operation` set to a value other than 'ready' or 'rewrap' (e.g. a custom/failed maintenance marker), and a batch rewrap call is made against that state.","commonSituations":"An operator manually updated `execution_payload_state.operation` to another value during an intervention; a crashed or older tool version wrote an unknown operation value; two adapter versions disagree on the set of valid operation strings in the same database.","solutions":["Inspect `SELECT operation FROM execution_payload_state WHERE component='signed_transactions'` and resolve whatever maintenance operation is in progress (complete or roll it back to 'ready' or 'rewrap').","Ensure only one maintenance process runs at a time — the advisory/table lock (`lock_execution_payload_operation`) only excludes other lock-aware processes, not manual edits.","If the value was written by an incompatible/older tool, run that tool's completion path or reset operation to 'ready' once storage is verified consistent.","Confirm all adapter instances use a version that shares the same operation vocabulary ('ready'/'rewrap')."],"exampleFix":"// before: DB row in unexpected state\nUPDATE execution_payload_state SET operation='paused' WHERE component='signed_transactions';\n-- after: keep operation within the supported vocabulary\nUPDATE execution_payload_state SET operation='ready', updated_at=NOW() WHERE component='signed_transactions';","handlingStrategy":"validation","validationCode":"let operation: String = sqlx::query_scalar(\"SELECT operation FROM execution_payload_state WHERE component = 'signed_transactions'\")\n    .fetch_one(&mut *tx).await?;\nif !matches!(operation.as_str(), \"ready\" | \"rewrap\") {\n    return Err(anyhow!(\"payload storage in unsupported maintenance state: {operation}\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only mutate `execution_payload_state.operation` through the library's maintenance functions, never via ad-hoc SQL.","Run a single maintenance/rewrap process at a time and serialize operators with runbooks.","Keep all adapter instances on the same version so the operation vocabulary is consistent.","Alert on any operation value outside {'ready','rewrap'} appearing in the state table."],"tags":["database","state-management","invalid-state-transition","encryption","rust"],"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"}