-
Notifications
You must be signed in to change notification settings - Fork 0
Description
We need the following changes:
Learn what happens if the client crashes, how long the server will be alive without MsgDone message. We want to know the current behaviour so we don't break it and inject the leashing behaviour safely. This will allow us to understand how exactly should the leashing message look like — how the client identifier should be included.
Note that if we consider switching to the its own leashing mini-protocol, we don't need client identifiers as all clients will be interpreted as the same one.
-
Add an optional client identifier to tweag/ouroboros-network@8aa240e
-
Changes for the ouroboros-consensus:
- update the ouroboros-network commit pin
- change the logic of the server
Ouroboros.Consensus.MiniProtocol.LocalStateQuery.Server (localStateQueryServer)to deal with different multiple clients with identifier - save the info who leashed the node
- so we could allow the unleashing with
MsgDoneinidlefor this client - tweag/ouroboros-consensus@c65cc4b
-
Update the cardano-api package with the client identifiers.
-
Update the pins of both ouroboros and cardano-api packages in cardano-node in https://github.com/tweag/cardano-node/tree/add-leashing-10.5.3
-
Update the pins in the plutus-script-reexecutor and use the client identifier.
The somewhat WIP branch https://github.com/tweag/plutus-reexec/tree/playing_with_leashing where we explore the leashing code on our side.
Helpful snippets:
`ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/LocalStateQuery/Server.hs`
39 39: recvMsgAcquire = \tgt leashed -> do
40 40: traceM $ "idle: handle acquire"
41 41: handleAcquire tgt leashed
42 42: , recvMsgDone =\mClientId = do
43: if leashed && Just leashingClient == mClientId then unleash
44: -- check if client identifier matches the one who leashed
45: -- atomically $ writeTVar leashingPointVar Nothing
42 46: return ()
43 47: }
44 48:
45 49: handleAcquire :: Target (Point blk)
...
50 54: getView mpt >>= \case
51 55: -- case if we want to leash and there is a leashing point var
52 56: Right forker
53 57: | leashed -> do
54 58: atomically $ do
55 59: traceM $ "SETTING LEASHING POINT VARIABLE"
56 60: readTVar leashingPointVar >>= \case
...
62 66: traceM $ "LEASHING POINT VARIABLE IS " <> show leashingPoint
63 67: pure $ SendMsgAcquired $ acquired True forker
64 68: -- return error if already leashed
65 69: Just _lp -> do
70: traceM $ "LEASHING POINT VARIABLE: " <> show lp
71: pure $ SendMsgAcquired $ acquired True forker
65 72: -- pure $ SendMsgFailure AcquireFailurePointStateIsBusy idle
66 73: Right forker -> pure $ SendMsgAcquired $ acquired False forker
67 74: Left PointTooOld{} -> pure $ SendMsgFailure AcquireFailurePointTooOld idle
68 75: Left PointNotOnChain -> pure $ SendMsgFailure AcquireFailurePointNotOnChain idle
`Cardano.Api.Internal.IPC.Monad`
setupLocalStateQueryExpr
:: STM x
-- ^ An STM expression that only returns when all protocols are complete.
-- Protocols must wait until 'waitDone' returns because premature exit will
-- cause other incomplete protocols to abort which may lead to deadlock.
-> Net.Query.Target ChainPoint
-> Bool
-> TMVar (Either AcquiringFailure a)
-> NodeToClientVersion
-> LocalStateQueryExpr BlockInMode ChainPoint QueryInMode () IO a
-> Net.Query.LocalStateQueryClient BlockInMode ChainPoint QueryInMode IO ()
setupLocalStateQueryExpr waitDone mPointVar' leashed resultVar' ntcVersion f =
LocalStateQueryClient . pure . Net.Query.SendMsgAcquire mPointVar' leashed $
Net.Query.ClientStAcquiring
{ Net.Query.recvMsgAcquired =
forever $ do
putStrLn "Doing things"
-- error "Something wrong happened"
-- let allQueries = runReaderT (runLocalStateQueryExpr f) ntcVersion
-- in runContT allQueries finalContinuation
, Net.Query.recvMsgFailure = \failure -> do