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

Add read locks to the Lua runner #260

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

maurermi
Copy link
Collaborator

This PR adds support for requesting read locks from Lua contracts. Now values yielded from contracts can include an optional second integer parameter (0 = read, else = write).

@HalosGhost HalosGhost requested a review from madars April 26, 2024 16:23
@HalosGhost
Copy link
Collaborator

CC @ayeshaali

@@ -10,7 +10,9 @@ function gen_bytecode()

function get_account(name)
account_key = get_account_key(name)
account_data = coroutine.yield(account_key)

-- 0 is read lock, 1 is write lock
Copy link
Member

Choose a reason for hiding this comment

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

perhaps consider using something more enum-like? https://unendli.ch/posts/2016-07-22-enumerations-in-lua.html

@maurermi maurermi force-pushed the support-lua-readlocks branch 3 times, most recently from 9d79b5c to 2a5b917 Compare July 12, 2024 14:18
@maurermi
Copy link
Collaborator Author

Update: Responded to comments from @eolesinski, additionally caught an error from testing in scripts/gen_bytecode.lua, and rebased onto trunk

Support requesting read locks from Lua contracts instead
of only write-locks.

Signed-off-by: Michael Maurer <[email protected]>
@maurermi
Copy link
Collaborator Author

@HalosGhost Added in a unit test that should make verification easier here

Signed-off-by: Michael Maurer <[email protected]>
Copy link
Collaborator

@HalosGhost HalosGhost left a comment

Choose a reason for hiding this comment

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

This is an excellent addition, enabling dramatically more performant/parallelization contracts in the lua runner (namely due to enabling multiple, concurrent read-locks on a given key).

@HalosGhost HalosGhost merged commit 6b399e1 into mit-dci:trunk Nov 14, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

4 participants