{"id":15822462,"url":"https://github.com/sambacha/ill","last_synced_at":"2026-02-18T04:33:50.289Z","repository":{"id":195360038,"uuid":"692767138","full_name":"sambacha/ill","owner":"sambacha","description":"intention lock conditional state library for the EVM","archived":false,"fork":false,"pushed_at":"2025-03-28T09:38:04.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T01:57:20.582Z","etag":null,"topics":["conditional","evm","locking","mutex","solidity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sambacha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-17T14:22:39.000Z","updated_at":"2025-03-28T09:38:07.000Z","dependencies_parsed_at":"2023-09-17T16:32:56.189Z","dependency_job_id":"54aa63c8-5e06-41cc-9d57-884f7e0fd8c2","html_url":"https://github.com/sambacha/ill","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"9a0507fa4d6ea37da17c6690e6c08a25e8564f79"},"previous_names":["sambacha/ill"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sambacha/ill","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sambacha","download_url":"https://codeload.github.com/sambacha/ill/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fill/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29568584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T04:18:28.490Z","status":"ssl_error","status_checked_at":"2026-02-18T04:13:49.018Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conditional","evm","locking","mutex","solidity"],"created_at":"2024-10-05T08:01:14.031Z","updated_at":"2026-02-18T04:33:45.279Z","avatar_url":"https://github.com/sambacha.png","language":"Solidity","readme":"# [ill](https://github.com/sambacha/ill/edit/master/README.md)\n\n\u003e inductive (intention) locking conditional state library\n\n\n`ill` implements a concurrent tree-like data structure, specifically a trie, where intermediary nodes represent prefixes of larger strings. The system aims to allow concurrent read and write access to strings in the trie. There's a need for locking not just the leaves (entire strings) but also intermediary nodes (prefixes of strings). \n\n### Invariants\n\nThe main challenge is to ensure concurrent access without violating two invariants:\n\n1. The owning thread can access any part of a node's subtree without additional locks.\n2. Other threads shouldn't be blocked from independent operations on different parts of the tree.\n\nA global reader-writer lock would easily ensure the first invariant but not the second. The solution proposed is to use _intention locks_ while traversing the prefix tree. \n\n**ill Locks:**\n\n- Intention locks are similar to reader-writer locks with multiple states.\n- States `S` (Shared) and `X` (Exclusive) are the primary states. A node in `S` or `X` implies all its descendants are similarly set.\n- Provisional intention states: `IS` (Intention to Share) and `IX` (Intention for Exclusive access) are introduced.\n  - `IS` allows a thread to continue traversing and set subsequent nodes to `IS` or `S`.\n  - `IX` allows a thread to continue traversing and set subsequent nodes to `IX` or `X`.\n  - `SIX` (Intention to Share and upgrade to IX) is mentioned but not implemented in this context.\n  \nTo lock a node in shared mode, all its ancestors are set to `IS` and the node itself to `S`. For exclusive mode, all ancestors are set to `IX` and the node to `X`.\n\n**Transition Matrix for Lock States:**\n\n| Request/Holding | Unlocked | Holding X | Holding S | Holding IX | Holding IS |\n|-----------------|----------|-----------|-----------|------------|------------|\n| Request X       | Yes      | No        | No        | No         | No         |\n| Request S       | Yes      | No        | Yes       | No         | Yes        |\n| Request IX      | Yes      | No        | No        | Yes        | Yes        |\n| Request IS      | Yes      | No        | Yes       | Yes        | Yes        |\n\n\u003e**Note**\n\u003e This matrix shows the allowed transitions between lock states. If a transition is not allowed, the caller MUST block.\n\n### Design\n\n\u003c!-- NOTES:\n\n- Potential bugs hide when the programmer believes a conditional (and thus the state it projects onto) means one thing when in fact it means something subtly different.\n\nState-transitions which allow interesting operational dynamics. To achieve it, we try to split all conditions apart from the state-transitions that they guard. We name each independently and combine to form real functions.\nThe problem with such conditional paths within transition logic is that they add conceptual non-linearity over state semantics. \n- Function bodies should have no conditional paths.   \n- Never mix transitions with conditions.   \n--\u003e\n\nAbstract the condition and create a function modifier for this condition.      \n\nExplicitly enumerate all such conditionals.   \n\nLogic becomes flattened into non-conditional state-transactions.     \n\n#### Base case\nWe show that there exists some state that is locked.       \n\n#### Inductive case\nGiven an arbitrary locked starting state (our inductive hypothesis), we show that the state remains locked after transition.    \n\n#### Assumptions\nWe assume that the user is not the contract itself.     \n\n### Specification\n\nWe must precisely model reentrancy (i.e. interprocedural control flow) so that we can then formalize each of these state transitions as a guarded transition rule. \n\nEach rule takes the form:\n  \n$$ (state, parameters) | condition → new_state $$\n\n\nwhere \n\n`state` and `new_state` are state tuples     \n\n`parameters` is a tuple of arguments for the transition     and \n`condition` is a predicate required for the transition to be valid.\n\nThese rules should hold for the following functions: `lockX`, `lockS`, `lockIX`, `lockIS`\n\n### Modifiers\n\n| Name                 | Description                       |\n|----------------------|-----------------------------------|\n| onlyOwner            | Checks caller is owner of node    |\n| canLockX             | Checks if X lock can be acquired  |\n| canLockS             | Checks if S lock can be acquired  |\n| canLockIX            | Checks if IX lock can be acquired |\n| canLockIS            | Checks if IS lock can be acquired |\n| rootNodeDoesNotExist | Checks root node does not exist   |\n| isValidParent        | Checks parent node index is valid |\n\n### Events\n\n| Name         | Description                     |\n|--------------|---------------------------------|\n| NodeAdded    | Emitted when a node is added    |\n| NodeLocked   | Emitted when a node is locked   |\n| NodeUnlocked | Emitted when a node is unlocked |\n\n\n## External Functions\n\n| Name         | Description      |\n|--------------|------------------|\n| addRootNode  | Adds root node   |\n| addChildNode | Adds child node  |\n| lockX        | Acquires X lock  |\n| lockS        | Acquires S lock  |\n| lockIX       | Acquires IX lock |\n| lockIS       | Acquires IS lock |\n| unlock       | Unlocks a node   |\n\n## Internal Functions\n\n| Name          | Description                                    |\n|---------------|------------------------------------------------|\n| _addRootNode  | Adds the root node                             |\n| _addChildNode | Adds a child node                              |\n| _lockNode     | Transitions a node to the specified lock state |\n| _unlockNode   | Unlocks a node                                 |\n\n\n## Data Model\n\n\n#### Enum: `LockState`\n\nThis enum represents the possible states of the lock for a node.\n\n| Value    | Description                                       |\n|----------|---------------------------------------------------|\n| Unlocked | The node is not locked by any user.               |\n| X        | The node is exclusively locked by a user.         |\n| S        | The node is shared, allowing concurrent reads.    |\n| IX       | Intention for exclusive access.                   |\n| IS       | Intention to share.                               |\n\n\n\n####  Struct: `Node`\n\nThis struct represents a node in the tree-like data structure.\n\n| Field        | Type     | Description                                        |\n|--------------|----------|----------------------------------------------------|\n| `state`      | LockState | The current state of the lock for this node.        |\n| `owner`      | address  | The Ethereum address of the owner of the lock.      |\n| `parentIndex`| uint     | The index of the parent node. 0 indicates root node.|\n\n\n#### Array: `tree`\n\nThis dynamic array represents the tree-like structure, where each element is a `Node`. The index of an element in this array serves as its unique identifier.\n\n| Index | Value |\n|-------|-------|\n| 0     | Root node of the tree (if it exists). |\n| 1...n | Other nodes in the tree. The order of addition determines the index. |\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambacha%2Fill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsambacha%2Fill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambacha%2Fill/lists"}