Skip to content

Commit

Permalink
Add review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed Nov 29, 2022
1 parent bbe9d8c commit 59bc3cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 38 deletions.
32 changes: 2 additions & 30 deletions hydra-node/json-schemas/logs.yaml
Expand Up @@ -409,34 +409,6 @@ definitions:

Node:
oneOf:
- title: ErrorHandlingEvent
# This should be removed from the Log's description as soon as we have some proper
# error handling strategy in place, be it simply "Close the head" and bail out.
description: >-
Some error happened while processing an event, provides enough context
information to troubleshoot the origin of the error.
type: object
additionalProperties: false
required:
- tag
- by
- event
properties:
tag:
type: string
enum: ["ErrorHandlingEvent"]
by:
<<: { "$ref": "api.yaml#/components/schemas/Party" }
description: >-
The Party emitting the log entry.
event:
<<: { "$ref": "#/definitions/Event" }
description: >-
The event causing the error.
reason:
<<: { "$ref": "#/definitions/LogicError" }
description: >-
Structured description of the cause of the error.
- title: BeginEvent
description: >-
Head has started processing an event drawn from some pool or queue of
Expand Down Expand Up @@ -518,7 +490,7 @@ definitions:
$ref: "#/definitions/Effect"
- title: LogicOutcome
description: >-
Outcome produced, to transition the Head protocol, after processing an input event.
An outcome produced is a decision the node took after processing an input event.
type: object
additionalProperties: false
required:
Expand Down Expand Up @@ -1182,7 +1154,7 @@ definitions:
- tag
- reason
description: >-
An outcome representing the time to wait by the node before re-enqueuing
An outcome representing the time that needs to pass before re-enqueuing
the input event to be processed again.
properties:
tag:
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/HeadLogic.hs
Expand Up @@ -247,7 +247,7 @@ deriving instance (IsTx tx, IsChainState tx) => Show (Outcome tx)
deriving instance (IsTx tx, IsChainState tx) => ToJSON (Outcome tx)
deriving instance (IsTx tx, IsChainState tx) => FromJSON (Outcome tx)

instance (IsTx tx, IsChainState tx) => Arbitrary (Outcome tx) where
instance (IsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (Outcome tx) where
arbitrary = genericArbitrary

data WaitReason
Expand Down
12 changes: 5 additions & 7 deletions hydra-node/src/Hydra/Node.hs
Expand Up @@ -43,7 +43,6 @@ import Hydra.HeadLogic (
Environment (..),
Event (..),
HeadState (..),
LogicError (..),
Outcome (..),
defaultTTL,
emitSnapshot,
Expand Down Expand Up @@ -87,8 +86,7 @@ data HydraNode tx m = HydraNode
}

data HydraNodeLog tx
= ErrorHandlingEvent {by :: Party, event :: Event tx, reason :: LogicError tx}
| BeginEvent {by :: Party, event :: Event tx}
= BeginEvent {by :: Party, event :: Event tx}
| EndEvent {by :: Party, event :: Event tx}
| BeginEffect {by :: Party, effect :: Effect tx}
| EndEffect {by :: Party, effect :: Effect tx}
Expand Down Expand Up @@ -134,14 +132,14 @@ stepHydraNode tracer node = do
case outcome of
-- TODO(SN): Handling of 'Left' is untested, i.e. the fact that it only
-- does trace and not throw!
Error err -> traceWith tracer (ErrorHandlingEvent party e err)
Wait _reason -> putEventAfter eq 0.1 (decreaseTTL e) >> traceWith tracer (EndEvent party e)
Error _ -> return ()
Wait _reason -> putEventAfter eq 0.1 (decreaseTTL e)
NewState s effs -> do
save s
forM_ effs (processEffect node tracer)
traceWith tracer (EndEvent party e)
OnlyEffects effs ->
forM_ effs (processEffect node tracer) >> traceWith tracer (EndEvent party e)
forM_ effs (processEffect node tracer)
traceWith tracer (EndEvent party e)
where
decreaseTTL =
\case
Expand Down

0 comments on commit 59bc3cc

Please sign in to comment.