Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFT] database error inserting batch transactions #2208

Open
smk762 opened this issue Sep 2, 2024 · 0 comments
Open

[NFT] database error inserting batch transactions #2208

smk762 opened this issue Sep 2, 2024 · 0 comments
Assignees

Comments

@smk762
Copy link

smk762 commented Sep 2, 2024

Describe the bug
When running update_nft, if the NFT transaction history returns batch transactions, a unique constraint database error is returned.

{
    "mmrpc": "2.0",
    "error": "DB error Rusqlite(SqliteFailure(Error { code: ConstraintViolation, extended_code: 1555 }, Some(\"UNIQUE constraint failed: MATIC_nft_transfer_history.transaction_hash, MATIC_nft_transfer_history.log_index\")))",
    "error_path": "nft.sql_storage",
    "error_trace": "nft:251] sql_storage:1075]",
    "error_type": "DbError",
    "error_data": "Rusqlite(SqliteFailure(Error { code: ConstraintViolation, extended_code: 1555 }, Some(\"UNIQUE constraint failed: MATIC_nft_transfer_history.transaction_hash, MATIC_nft_transfer_history.log_index\")))",
    "id": null
}

Further investigation revealed that the data returned from moralis included a few entries with the same transaction_hash and log_index (triggering the unique constraint) , but a different token_id.


        {
            "block_number": "54459927",
            "block_timestamp": "2024-03-09T17:35:51.000Z",
            "block_hash": "0xf2f64071e3b0c53da195229cae6413b10fa3e047b4ba637582267121e830c10b",
            "transaction_hash": "0x6a0e221abe0073b653cc30936a19b90302ffd79e65bc9a3c6605fce3952e4572",
            "transaction_index": 87,
            "log_index": 1186,
            "value": "0",
            "contract_type": "ERC1155",
            "transaction_type": "Batch",
            "token_address": "0xf3fc2a3d15453515039d292d7c0d3d7514a93668",
            "token_id": "2",
            "from_address_entity": null,
            "from_address_entity_logo": null,
            "from_address": "0x6f8a06447ff6fcf75d803135a7de15ce88c1d4ec",
            "from_address_label": "SHIBA INU (PoS) (SHIB)",
            "to_address_entity": null,
            "to_address_entity_logo": null,
            "to_address": "0xab95d01bc8214e4d993043e8ca1b68db2c946498",
            "to_address_label": null,
            "amount": "1",
            "verified": 0,
            "operator": "0x6f8a06447ff6fcf75d803135a7de15ce88c1d4ec",
            "possible_spam": true,
            "verified_collection": false
        },
        {
            "block_number": "54459927",
            "block_timestamp": "2024-03-09T17:35:51.000Z",
            "block_hash": "0xf2f64071e3b0c53da195229cae6413b10fa3e047b4ba637582267121e830c10b",
            "transaction_hash": "0x6a0e221abe0073b653cc30936a19b90302ffd79e65bc9a3c6605fce3952e4572",
            "transaction_index": 87,
            "log_index": 1186,
            "value": "0",
            "contract_type": "ERC1155",
            "transaction_type": "Batch",
            "token_address": "0xf3fc2a3d15453515039d292d7c0d3d7514a93668",
            "token_id": "1",
            "from_address_entity": null,
            "from_address_entity_logo": null,
            "from_address": "0x6f8a06447ff6fcf75d803135a7de15ce88c1d4ec",
            "from_address_label": "SHIBA INU (PoS) (SHIB)",
            "to_address_entity": null,
            "to_address_entity_logo": null,
            "to_address": "0xab95d01bc8214e4d993043e8ca1b68db2c946498",
            "to_address_label": null,
            "amount": "1",
            "verified": 0,
            "operator": "0x6f8a06447ff6fcf75d803135a7de15ce88c1d4ec",
            "possible_spam": true,
            "verified_collection": false
        },
        {
            "block_number": "54459927",
            "block_timestamp": "2024-03-09T17:35:51.000Z",
            "block_hash": "0xf2f64071e3b0c53da195229cae6413b10fa3e047b4ba637582267121e830c10b",
            "transaction_hash": "0x6a0e221abe0073b653cc30936a19b90302ffd79e65bc9a3c6605fce3952e4572",
            "transaction_index": 87,
            "log_index": 1186,
            "value": "0",
            "contract_type": "ERC1155",
            "transaction_type": "Batch",
            "token_address": "0xf3fc2a3d15453515039d292d7c0d3d7514a93668",
            "token_id": "0",
            "from_address_entity": null,
            "from_address_entity_logo": null,
            "from_address": "0x6f8a06447ff6fcf75d803135a7de15ce88c1d4ec",
            "from_address_label": "SHIBA INU (PoS) (SHIB)",
            "to_address_entity": null,
            "to_address_entity_logo": null,
            "to_address": "0xab95d01bc8214e4d993043e8ca1b68db2c946498",
            "to_address_label": null,
            "amount": "1",
            "verified": 0,
            "operator": "0x6f8a06447ff6fcf75d803135a7de15ce88c1d4ec",
            "possible_spam": true,
            "verified_collection": false
}

Solution should be to simply include the token_id column in the unique constraint group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants