@@ -126,9 +126,8 @@ onIdleChainInitTx ::
126
126
HeadSeed ->
127
127
HeadParameters ->
128
128
[OnChainId ] ->
129
- Word64 ->
130
129
Outcome tx
131
- onIdleChainInitTx env newChainState headId headSeed headParameters participants nextStateChangeID
130
+ onIdleChainInitTx env newChainState headId headSeed headParameters participants
132
131
| configuredParties == initializedParties
133
132
&& party `member` initializedParties
134
133
&& configuredContestationPeriod == contestationPeriod
@@ -139,7 +138,6 @@ onIdleChainInitTx env newChainState headId headSeed headParameters participants
139
138
, chainState = newChainState
140
139
, headId
141
140
, headSeed
142
- , stateChangeID = nextStateChangeID
143
141
}
144
142
<> cause (ClientEffect $ ServerOutput. HeadIsInitializing {headId, parties})
145
143
| otherwise =
@@ -179,10 +177,9 @@ onInitialChainCommitTx ::
179
177
Party ->
180
178
-- | Committed UTxO
181
179
UTxOType tx ->
182
- Word64 ->
183
180
Outcome tx
184
- onInitialChainCommitTx st newChainState pt utxo nextStateChangeID =
185
- newState CommittedUTxO {party = pt, committedUTxO = utxo, chainState = newChainState, stateChangeID = nextStateChangeID }
181
+ onInitialChainCommitTx st newChainState pt utxo =
182
+ newState CommittedUTxO {party = pt, committedUTxO = utxo, chainState = newChainState}
186
183
<> causes
187
184
( notifyClient
188
185
: [postCollectCom | canCollectCom]
@@ -231,10 +228,9 @@ onInitialChainAbortTx ::
231
228
ChainStateType tx ->
232
229
Committed tx ->
233
230
HeadId ->
234
- Word64 ->
235
231
Outcome tx
236
- onInitialChainAbortTx newChainState committed headId nextStateChangeID =
237
- newState HeadAborted {chainState = newChainState, stateChangeID = nextStateChangeID }
232
+ onInitialChainAbortTx newChainState committed headId =
233
+ newState HeadAborted {chainState = newChainState}
238
234
<> cause (ClientEffect $ ServerOutput. HeadIsAborted {headId, utxo = fold committed})
239
235
240
236
-- | Observe a collectCom transaction. We initialize the 'OpenState' using the
@@ -247,10 +243,9 @@ onInitialChainCollectTx ::
247
243
InitialState tx ->
248
244
-- | New chain state
249
245
ChainStateType tx ->
250
- Word64 ->
251
246
Outcome tx
252
- onInitialChainCollectTx st newChainState nextStateChangeID =
253
- newState HeadOpened {chainState = newChainState, initialUTxO = u0, stateChangeID = nextStateChangeID }
247
+ onInitialChainCollectTx st newChainState =
248
+ newState HeadOpened {chainState = newChainState, initialUTxO = u0}
254
249
<> cause (ClientEffect $ ServerOutput. HeadIsOpen {headId, utxo = u0})
255
250
where
256
251
u0 = fold committed
@@ -288,24 +283,23 @@ onOpenNetworkReqTx ::
288
283
TTL ->
289
284
-- | The transaction to be submitted to the head.
290
285
tx ->
291
- Word64 ->
292
286
Outcome tx
293
- onOpenNetworkReqTx env ledger st ttl tx nextStateChangeID =
287
+ onOpenNetworkReqTx env ledger st ttl tx =
294
288
-- Spec: Tall ← ̂Tall ∪ { (hash(tx), tx) }
295
- (newState TransactionReceived {tx, stateChangeID = nextStateChangeID } <> ) $
289
+ (newState TransactionReceived {tx} <> ) $
296
290
-- Spec: wait L̂ ◦ tx ≠ ⊥ combined with L̂ ← L̂ ◦ tx
297
291
waitApplyTx $ \ newLocalUTxO ->
298
292
-- Spec: if ŝ = s̄ ∧ leader(s̄ + 1) = i
299
293
( if not snapshotInFlight && isLeader parameters party nextSn
300
294
then
301
- newState TransactionAppliedToLocalUTxO {tx = tx, newLocalUTxO, stateChangeID = nextStateChangeID }
295
+ newState TransactionAppliedToLocalUTxO {tx = tx, newLocalUTxO}
302
296
<>
303
297
-- XXX: This state update has no equivalence in the
304
298
-- spec. Do we really need to store that we have
305
299
-- requested a snapshot? If yes, should update spec.
306
- newState SnapshotRequestDecided {snapshotNumber = nextSn, stateChangeID = nextStateChangeID }
300
+ newState SnapshotRequestDecided {snapshotNumber = nextSn}
307
301
<> cause (NetworkEffect $ ReqSn nextSn (txId <$> localTxs'))
308
- else newState TransactionAppliedToLocalUTxO {tx, newLocalUTxO, stateChangeID = nextStateChangeID }
302
+ else newState TransactionAppliedToLocalUTxO {tx, newLocalUTxO}
309
303
)
310
304
<> cause (ClientEffect $ ServerOutput. TxValid headId tx)
311
305
where
@@ -371,9 +365,8 @@ onOpenNetworkReqSn ::
371
365
SnapshotNumber ->
372
366
-- | List of transactions to snapshot.
373
367
[TxIdType tx ] ->
374
- Word64 ->
375
368
Outcome tx
376
- onOpenNetworkReqSn env ledger st otherParty sn requestedTxIds nextStateChangeID =
369
+ onOpenNetworkReqSn env ledger st otherParty sn requestedTxIds =
377
370
-- TODO: Verify the request is signed by (?) / comes from the leader
378
371
-- (Can we prove a message comes from a given peer, without signature?)
379
372
@@ -402,7 +395,6 @@ onOpenNetworkReqSn env ledger st otherParty sn requestedTxIds nextStateChangeID
402
395
, requestedTxIds
403
396
, newLocalUTxO
404
397
, newLocalTxs
405
- , stateChangeID = nextStateChangeID
406
398
}
407
399
where
408
400
requireReqSn continue
@@ -484,9 +476,8 @@ onOpenNetworkAckSn ::
484
476
Signature (Snapshot tx ) ->
485
477
-- | Snapshot number of this AckSn.
486
478
SnapshotNumber ->
487
- Word64 ->
488
479
Outcome tx
489
- onOpenNetworkAckSn Environment {party} openState otherParty snapshotSignature sn nextStateChangeID =
480
+ onOpenNetworkAckSn Environment {party} openState otherParty snapshotSignature sn =
490
481
-- TODO: verify authenticity of message and whether otherParty is part of the head
491
482
-- Spec: require s ∈ {ŝ, ŝ + 1}
492
483
requireValidAckSn $ do
@@ -499,7 +490,7 @@ onOpenNetworkAckSn Environment{party} openState otherParty snapshotSignature sn
499
490
let multisig = aggregateInOrder sigs' parties
500
491
requireVerifiedMultisignature multisig snapshot $
501
492
do
502
- newState SnapshotConfirmed {snapshot, signatures = multisig, stateChangeID = nextStateChangeID }
493
+ newState SnapshotConfirmed {snapshot, signatures = multisig}
503
494
<> cause (ClientEffect $ ServerOutput. SnapshotConfirmed headId snapshot multisig)
504
495
& maybeEmitSnapshot
505
496
where
@@ -531,7 +522,6 @@ onOpenNetworkAckSn Environment{party} openState otherParty snapshotSignature sn
531
522
{ snapshot
532
523
, party = otherParty
533
524
, signature = snapshotSignature
534
- , stateChangeID = nextStateChangeID
535
525
}
536
526
537
527
requireVerifiedMultisignature multisig msg cont =
@@ -550,7 +540,7 @@ onOpenNetworkAckSn Environment{party} openState otherParty snapshotSignature sn
550
540
if isLeader parameters party nextSn && not (null localTxs)
551
541
then
552
542
outcome
553
- <> newState SnapshotRequestDecided {snapshotNumber = nextSn, stateChangeID = nextStateChangeID }
543
+ <> newState SnapshotRequestDecided {snapshotNumber = nextSn}
554
544
<> cause (NetworkEffect $ ReqSn nextSn (txId <$> localTxs))
555
545
else outcome
556
546
@@ -595,10 +585,9 @@ onOpenChainCloseTx ::
595
585
SnapshotNumber ->
596
586
-- | Contestation deadline.
597
587
UTCTime ->
598
- Word64 ->
599
588
Outcome tx
600
- onOpenChainCloseTx openState newChainState closedSnapshotNumber contestationDeadline nextStateChangeID =
601
- newState HeadClosed {chainState = newChainState, contestationDeadline, stateChangeID = nextStateChangeID }
589
+ onOpenChainCloseTx openState newChainState closedSnapshotNumber contestationDeadline =
590
+ newState HeadClosed {chainState = newChainState, contestationDeadline}
602
591
<> causes
603
592
( notifyClient
604
593
: [ OnChainEffect
@@ -634,10 +623,9 @@ onClosedChainContestTx ::
634
623
SnapshotNumber ->
635
624
-- | Contestation deadline.
636
625
UTCTime ->
637
- Word64 ->
638
626
Outcome tx
639
- onClosedChainContestTx closedState newChainState snapshotNumber contestationDeadline nextStateChangeID =
640
- newState HeadContested {chainState = newChainState, contestationDeadline, stateChangeID = nextStateChangeID }
627
+ onClosedChainContestTx closedState newChainState snapshotNumber contestationDeadline =
628
+ newState HeadContested {chainState = newChainState, contestationDeadline}
641
629
<> if
642
630
| snapshotNumber < number (getSnapshot confirmedSnapshot) ->
643
631
cause notifyClients
@@ -681,10 +669,9 @@ onClosedChainFanoutTx ::
681
669
ClosedState tx ->
682
670
-- | New chain state
683
671
ChainStateType tx ->
684
- Word64 ->
685
672
Outcome tx
686
- onClosedChainFanoutTx closedState newChainState nextStateChangeID =
687
- newState HeadFannedOut {chainState = newChainState, stateChangeID = nextStateChangeID }
673
+ onClosedChainFanoutTx closedState newChainState =
674
+ newState HeadFannedOut {chainState = newChainState}
688
675
<> cause (ClientEffect $ ServerOutput. HeadIsFinalized {headId, utxo})
689
676
where
690
677
Snapshot {utxo} = getSnapshot confirmedSnapshot
@@ -698,27 +685,26 @@ update ::
698
685
IsChainState tx =>
699
686
Environment ->
700
687
Ledger tx ->
701
- Word64 ->
702
688
-- | Current HeadState to validate the command against.
703
689
HeadState tx ->
704
690
-- | Input to be processed.
705
691
Input tx ->
706
692
Outcome tx
707
- update env ledger nextStateChangeID st ev = case (st, ev) of
693
+ update env ledger st ev = case (st, ev) of
708
694
(Idle _, ClientInput Init ) ->
709
695
onIdleClientInit env
710
696
(Idle _, ChainInput Observation {observedTx = OnInitTx {headId, headSeed, headParameters, participants}, newChainState}) ->
711
- onIdleChainInitTx env newChainState headId headSeed headParameters participants nextStateChangeID
697
+ onIdleChainInitTx env newChainState headId headSeed headParameters participants
712
698
(Initial initialState@ InitialState {headId = ourHeadId}, ChainInput Observation {observedTx = OnCommitTx {headId, party = pt, committed = utxo}, newChainState})
713
- | ourHeadId == headId -> onInitialChainCommitTx initialState newChainState pt utxo nextStateChangeID
699
+ | ourHeadId == headId -> onInitialChainCommitTx initialState newChainState pt utxo
714
700
| otherwise -> Error NotOurHead {ourHeadId, otherHeadId = headId}
715
701
(Initial initialState, ClientInput Abort ) ->
716
702
onInitialClientAbort initialState
717
703
(Initial initialState@ InitialState {headId = ourHeadId}, ChainInput Observation {observedTx = OnCollectComTx {headId}, newChainState})
718
- | ourHeadId == headId -> onInitialChainCollectTx initialState newChainState nextStateChangeID
704
+ | ourHeadId == headId -> onInitialChainCollectTx initialState newChainState
719
705
| otherwise -> Error NotOurHead {ourHeadId, otherHeadId = headId}
720
706
(Initial InitialState {headId = ourHeadId, committed}, ChainInput Observation {observedTx = OnAbortTx {headId}, newChainState})
721
- | ourHeadId == headId -> onInitialChainAbortTx newChainState committed headId nextStateChangeID
707
+ | ourHeadId == headId -> onInitialChainAbortTx newChainState committed headId
722
708
| otherwise -> Error NotOurHead {ourHeadId, otherHeadId = headId}
723
709
(Initial InitialState {committed, headId}, ClientInput GetUTxO ) ->
724
710
cause (ClientEffect . ServerOutput. GetUTxOResponse headId $ fold committed)
@@ -728,18 +714,18 @@ update env ledger nextStateChangeID st ev = case (st, ev) of
728
714
(Open {}, ClientInput (NewTx tx)) ->
729
715
onOpenClientNewTx tx
730
716
(Open openState, NetworkInput ttl _ (ReqTx tx)) ->
731
- onOpenNetworkReqTx env ledger openState ttl tx nextStateChangeID
717
+ onOpenNetworkReqTx env ledger openState ttl tx
732
718
(Open openState, NetworkInput _ otherParty (ReqSn sn txIds)) ->
733
719
-- XXX: ttl == 0 not handled for ReqSn
734
- onOpenNetworkReqSn env ledger openState otherParty sn txIds nextStateChangeID
720
+ onOpenNetworkReqSn env ledger openState otherParty sn txIds
735
721
(Open openState, NetworkInput _ otherParty (AckSn snapshotSignature sn)) ->
736
722
-- XXX: ttl == 0 not handled for AckSn
737
- onOpenNetworkAckSn env openState otherParty snapshotSignature sn nextStateChangeID
723
+ onOpenNetworkAckSn env openState otherParty snapshotSignature sn
738
724
( Open openState@ OpenState {headId = ourHeadId}
739
725
, ChainInput Observation {observedTx = OnCloseTx {headId, snapshotNumber = closedSnapshotNumber, contestationDeadline}, newChainState}
740
726
)
741
727
| ourHeadId == headId ->
742
- onOpenChainCloseTx openState newChainState closedSnapshotNumber contestationDeadline nextStateChangeID
728
+ onOpenChainCloseTx openState newChainState closedSnapshotNumber contestationDeadline
743
729
| otherwise ->
744
730
Error NotOurHead {ourHeadId, otherHeadId = headId}
745
731
(Open OpenState {coordinatedHeadState = CoordinatedHeadState {confirmedSnapshot}, headId}, ClientInput GetUTxO ) ->
@@ -753,34 +739,31 @@ update env ledger nextStateChangeID st ev = case (st, ev) of
753
739
-- Closed
754
740
(Closed closedState@ ClosedState {headId = ourHeadId}, ChainInput Observation {observedTx = OnContestTx {headId, snapshotNumber, contestationDeadline}, newChainState})
755
741
| ourHeadId == headId ->
756
- onClosedChainContestTx closedState newChainState snapshotNumber contestationDeadline nextStateChangeID
742
+ onClosedChainContestTx closedState newChainState snapshotNumber contestationDeadline
757
743
| otherwise ->
758
744
Error NotOurHead {ourHeadId, otherHeadId = headId}
759
745
(Closed ClosedState {contestationDeadline, readyToFanoutSent, headId}, ChainInput Tick {chainTime})
760
746
| chainTime > contestationDeadline && not readyToFanoutSent ->
761
- newState HeadIsReadyToFanout {stateChangeID = nextStateChangeID}
747
+ newState HeadIsReadyToFanout
762
748
<> cause (ClientEffect $ ServerOutput. ReadyToFanout headId)
763
749
(Closed closedState, ClientInput Fanout ) ->
764
750
onClosedClientFanout closedState
765
751
(Closed closedState@ ClosedState {headId = ourHeadId}, ChainInput Observation {observedTx = OnFanoutTx {headId}, newChainState})
766
752
| ourHeadId == headId ->
767
- onClosedChainFanoutTx closedState newChainState nextStateChangeID
753
+ onClosedChainFanoutTx closedState newChainState
768
754
| otherwise ->
769
755
Error NotOurHead {ourHeadId, otherHeadId = headId}
770
756
-- General
771
757
(_, ChainInput Rollback {rolledBackChainState}) ->
772
- newState ChainRolledBack {chainState = rolledBackChainState, stateChangeID }
758
+ newState ChainRolledBack {chainState = rolledBackChainState}
773
759
(_, ChainInput Tick {chainSlot}) ->
774
- newState TickObserved {chainSlot, stateChangeID}
775
- -- FIXME(Elaine): should this bump the stateChangeID as well?
760
+ newState TickObserved {chainSlot}
776
761
(_, ChainInput PostTxError {postChainTx, postTxError}) ->
777
762
cause . ClientEffect $ ServerOutput. PostTxOnChainFailed {postChainTx, postTxError}
778
763
(_, ClientInput {clientInput}) ->
779
764
cause . ClientEffect $ ServerOutput. CommandFailed clientInput st
780
765
_ ->
781
766
Error $ UnhandledInput ev st
782
- where
783
- stateChangeID = nextStateChangeID
784
767
785
768
-- * HeadState aggregate
786
769
0 commit comments