Skip to content

Add set of currently active leash clients to LsqLeashingState#21

Open
axman6 wants to merge 2 commits intoadd-leashing-0.30.0.1from
add-leashing-0.30.0.1-known-clients
Open

Add set of currently active leash clients to LsqLeashingState#21
axman6 wants to merge 2 commits intoadd-leashing-0.30.0.1from
add-leashing-0.30.0.1-known-clients

Conversation

@axman6
Copy link
Copy Markdown

@axman6 axman6 commented Mar 17, 2026

Closes tweag/plutus-script-reexecutor#161

Adds a set of currently known leashing client IDs - LeashId's which currently have active connections to clients (and hence an active thread which can update that ID's leash). This should be a subset of all the IDs in the keys of the leash fragments map.

Also note that:

  • It is possible that a client sends a new LeashId when in the Idle state, which does not match the previous LeashId from that connection. Currently I'm not checking for or handling that case because I'm not sure what the appropriate action is:

    1. Return a new error to the client
    2. Release the leash for the previous LeashId (and remove it from the active set) - see releaseLeash.
  • I haven't made any changes to the protocol constructors, so the error case when a LeashId is reused currently sends AcquireFailurePointNotOnChain. This should probably be a new error constructor. MsgDone also no longer needs the Maybe LeashId, if there is a known ID it will be passed into the idle function.

@axman6 axman6 requested review from adithyaov and tweag-ev-ak March 17, 2026 04:02
@axman6 axman6 requested a review from nfrisby as a code owner March 17, 2026 04:02

varLsqLeashingState <- newTVarIO $ mempty
varGenesisLoEFragment <- newTVarIO LoEDisabled
varLsqLeashingState <- newTVarIO $ LsqLeashingState Map.empty Set.empty
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This might need to be extended to support the set of expected leash clients @tweag-ev-ak was working on to prevent progress before clients are able to connect.

idle :: ServerStIdle blk (Point blk) (Query blk) m ()
idle =
idle :: Maybe LeashId -> ServerStIdle blk (Point blk) (Query blk) m ()
idle clientLeashId =
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

All states now know this thread's client's LeashId if the client provided one.

lsqLeashingState <- readTVar lsqLeashingStateVar
let newState = Map.delete leashId lsqLeashingState
writeTVar lsqLeashingStateVar newState
releaseLeash leashId = do
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Always removed the leash and the active client ID - maintains the set of active clients always being a subset of the known leashes.

in (toList $ lsqActiveClients l', l')
traceM $ "currently live clients: " <> show active

deactivateLeashClient :: Maybe LeashId -> m ()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Only removes the active client ID.

@axman6 axman6 force-pushed the add-leashing-0.30.0.1-known-clients branch 2 times, most recently from bddbd43 to e4e7c5b Compare March 17, 2026 05:57
@axman6 axman6 force-pushed the add-leashing-0.30.0.1-known-clients branch from e4e7c5b to 8097d2f Compare March 17, 2026 06:32
@tweag-ev-ak tweag-ev-ak force-pushed the add-leashing-0.30.0.1 branch from c155bf7 to 9f9c384 Compare March 30, 2026 05:10
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.

1 participant