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

Solve contract deadlocks delaying progress of QVAULT #301

Merged
merged 4 commits into from
Feb 10, 2025

Conversation

philippwerner
Copy link
Contributor

This solves the deadlock happening when QX::TransferShareManagementRights() is invoked from another contract C2, see issue #296

C2 invokes a procedure of C1 (e.g., QX) that calls qpi.releaseShares() for transferring management rights to C2. The state of contract C2 is already locked for writing when C1 is calling qpi.releaseShares(), which tries to acquire the write lock again (all in the same processor).

This PR should solve all similar deadlocks with callbacks if no other processor is involved (no parallel contract function calls locking states next to contract procedure).

- improve robustness in case of wrong use and memory corruption
- add unwind() to support in contract error handling
- add "special block" flag, to mark blocks that need to be processed
  in error handling
This solves the deadlock happening when QX::TransferShareManagementRights()
is invoked from another contract C2.

C2 invokes a procedure of C1 (e.g., QX) that calls qpi.releaseShares()
for transferring management rights to C2.  The state of contract C2 is
already locked for writing when C1 is calling qpi.releaseShares(), which
tries to acquire the write lock again (all in the same processor).

This commit should solve all similar deadlocks with callbacks if no
other processor is involved (no parallel contract function calls locking
states next to contract procedure).
@Franziska-Mueller Franziska-Mueller self-requested a review February 10, 2025 15:34
Copy link
Collaborator

@Franziska-Mueller Franziska-Mueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me! only found some typos

@philippwerner philippwerner merged commit e5e0c1f into develop Feb 10, 2025
1 check passed
@philippwerner philippwerner deleted the feature/2025-02-05-solve-contract-deadlocks branch February 10, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants