Skip to content

Commit

Permalink
Add AssertionFailed logic error outcome and use it onDecrementTx
Browse files Browse the repository at this point in the history
This, at least, results in log lines if this situation occurrs.
  • Loading branch information
ch1bo committed Jul 17, 2024
1 parent 51852cf commit deb4923
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions hydra-node/json-schemas/logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,20 @@ definitions:
requirementFailure:
$ref: "logs.yaml#/definitions/RequirementFailure"

- title: AssertionFailed
description: >-
An unexpected situation arose in the implementation of the protocol logic. This is different to 'RequireFailed' as these conditions are not defined in the specified protocol.
additionalProperties: false
required:
- tag
- message
properties:
tag:
type: string
enum: ["AssertionFailed"]
message:
type: string

- title: NotOurHead
description: >-
We just observed an on-chain event that does not apply to
Expand Down
4 changes: 2 additions & 2 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ onOpenChainDecrementTx ::
onOpenChainDecrementTx Environment{party} openState newVersion distributedTxOuts =
-- Spec: if outputs(txω) = 𝑈ω
case decommitTx of
Nothing -> noop -- TODO: what if decommit observed but none pending?
Nothing -> Error $ AssertionFailed "decrement observed but no decommit pending"
Just tx
| outputsOfTx tx == distributedTxOuts ->
-- Spec: txω ← ⊥
Expand All @@ -854,7 +854,7 @@ onOpenChainDecrementTx Environment{party} openState newVersion distributedTxOuts
-- Spec: if ŝ = ̅S.s ∧ leader(̅S.s + 1) = i
-- multicast (reqSn, v, ̅S.s + 1, T̂ , txω )
& maybeRequestSnapshot
| otherwise -> noop -- TODO: what if decrement not matching pending decommit?
| otherwise -> Error $ AssertionFailed "decrement not matching pending decommit"
where
maybeRequestSnapshot outcome =
if seenSn == confirmedSn && isLeader parameters party nextSn
Expand Down
1 change: 1 addition & 0 deletions hydra-node/src/Hydra/HeadLogic/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Hydra.Snapshot (SnapshotNumber, SnapshotVersion)
data LogicError tx
= UnhandledInput {input :: Input tx, currentHeadState :: HeadState tx}
| RequireFailed {requirementFailure :: RequirementFailure tx}
| AssertionFailed {message :: Text}
| NotOurHead {ourHeadId :: HeadId, otherHeadId :: HeadId}
deriving stock (Generic)

Expand Down

0 comments on commit deb4923

Please sign in to comment.