Skip to content

IndexError: pop from an empty deque on tree.get_state() #29

@ganguera

Description

@ganguera

Hi @fmerg,

Thanks for sharing this cool project.

I'm currently working on stress testing my application, and I've encountered an issue that I believe is related to the codebase. During the stress test, I'm intermittently receiving an "IndexError: pop from an empty deque" error coming from "tree.get_state()".

Under normal circumstances it seems to be functioning correctly, however under stress conditions with many clients, this error is triggered. I've reviewed the code and I've seen you already profiled that particular section of code which made me think maybe is a known issue.

I'm reaching out to see if you or anyone else has encountered a similar issue or if you have any insights into what might be causing this error. Your expertise in this matter would be greatly appreciated.

Thank you in advance for your help. Please let me know if you need more information or if you'd like to discuss this further.

Best regards,
Guillem

def add_record(count, payload):
    leaf_index = tree.append_entry(payload)
    leaf_hash = tree.get_leaf(leaf_index)
    tree_state = tree.get_state(leaf_index)
    tree_index = tree.append_log(leaf_id=leaf_index, digest=tree_state)
    return leaf_index, leaf_hash, tree_index, tree_state
Traceback (most recent call last):
    File "/app/app/controllers/tree.py", line 85, in add_record
        tree_state = tree.get_state(leaf_index)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/pymerkle/core.py", line 146, in get_state
        return self._get_root(0, size)
               ^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/pymerkle/core.py", line 379, in _get_root
        node = _get_subroot(offset, width)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/pymerkle/core.py", line 304, in _get_subroot
        return self._get_subroot_uncached(offset, width)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/pymerkle/core.py", line 348, in _get_subroot_uncached
        rnode = popleft()
                ^^^^^^^^^
IndexError: pop from an empty deque

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions