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

[Bug] Fail to resync the wallet #16589

Closed
YeungTing opened this issue Oct 11, 2023 · 4 comments
Closed

[Bug] Fail to resync the wallet #16589

YeungTing opened this issue Oct 11, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@YeungTing
Copy link
Contributor

YeungTing commented Oct 11, 2023

What happened?

Fail to resync the wallet.

if old_records is too long, the sql error

async def _get_new_tx_records_from_old(self, old_records: List[TransactionRecordOld]) -> List[TransactionRecord]:
    async with self.db_wrapper.reader_no_transaction() as conn:
        cursor = await conn.execute(
            f"SELECT txid, valid_times from tx_times WHERE txid IN ({','.join('?' *  len(old_records))})",
            tuple(tx.name for tx in old_records),
        )
        valid_times: Dict[bytes32, ConditionValidTimes] = {
            bytes32(res[0]): ConditionValidTimes.from_bytes(res[1]) for res in await cursor.fetchall()
        }
        await cursor.close()
    return [
        TransactionRecord(
            valid_times=valid_times[record.name] if record.name in valid_times else ConditionValidTimes(),
            spend_bundle=record.spend_bundle,
            **{k: v for k, v in dataclasses.asdict(record).items() if k != "spend_bundle"},
        )
        for record in old_records
    ]

Version

2.1.0

What platform are you using?

Windows

What ui mode are you using?

GUI

Relevant log output

2023-10-11T21:58:19.839 wallet chia.wallet.wallet_node    : ERROR    Exception while perform_atomic_rollback: too many SQL variables Traceback (most recent call last):
  File "C:\Chia\chia-blockchain-2.1.0.Official\chia-blockchain\chia\wallet\wallet_node.py", line 708, in perform_atomic_rollback
    removed_wallet_ids = await self.wallet_state_manager.reorg_rollback(fork_height)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Chia\chia-blockchain-2.1.0.Official\chia-blockchain\chia\wallet\wallet_state_manager.py", line 2099, in reorg_rollback
    reorged: List[TransactionRecord] = await self.tx_store.get_transaction_above(height)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Chia\chia-blockchain-2.1.0.Official\chia-blockchain\chia\wallet\wallet_transaction_store.py", line 402, in get_transaction_above
    return await self._get_new_tx_records_from_old([TransactionRecordOld.from_bytes(row[0]) for row in rows])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Chia\chia-blockchain-2.1.0.Official\chia-blockchain\chia\wallet\wallet_transaction_store.py", line 432, in _get_new_tx_records_from_old
    cursor = await conn.execute(
             ^^^^^^^^^^^^^^^^^^^
  File "C:\Chia\chia-blockchain-2.1.0.Official\chia-blockchain\venv\Lib\site-packages\aiosqlite\core.py", line 190, in execute
    cursor = await self._execute(self._conn.execute, sql, parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Chia\chia-blockchain-2.1.0.Official\chia-blockchain\venv\Lib\site-packages\aiosqlite\core.py", line 133, in _execute
    return await future
           ^^^^^^^^^^^^
  File "C:\Chia\chia-blockchain-2.1.0.Official\chia-blockchain\venv\Lib\site-packages\aiosqlite\core.py", line 106, in run
    result = function()
             ^^^^^^^^^^
sqlite3.OperationalError: too many SQL variables
@YeungTing YeungTing added the bug Something isn't working label Oct 11, 2023
@wjblanke
Copy link
Contributor

Looks like this

tuple(tx.name for tx in old_records)

should use sub_record

Thanks!!!!

@Quexington
Copy link
Contributor

Agreed, but this code is not in main???

@YeungTing
Copy link
Contributor Author

YeungTing commented Oct 11, 2023

Sorry, i pasted wrong code there, updated now. Please look the main code instead

It was my trial to fix it, but not working, please ignore my previous code pasted in the issue

@wjblanke
Copy link
Contributor

This should be fixed in main and the next release now. Thanks for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants