-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADR 18: Keeping a single state #305
Conversation
0d795c2
to
8888017
Compare
* The interface between the `Hydra.Node` and a `Hydra.Chain` component consists of | ||
- constructing certain Head protocol transactions given a description of it (`PostChainTx tx`): | ||
```hs | ||
postTx :: MonadThrow m => PostChainTx tx -> m () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this first point is really about the interface between the Hydra.Node
and the Hydra.Chain
. This is really the client interface and how clients can interact with the on-chain state.
Nevermind. We do indeed use this handle as a mean between the two components, postChainTx
calls are a result of effects emitted by the head logic in response to client inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow I keep getting "confused" by this 🤔 ... Maybe just a naming question.
* We provide the latest `ChainState tx` to `postTx` by extending `PostChainTx tx` | ||
* We change the callback interface of `Chain` to | ||
```hs | ||
type ChainCallback tx m = (ChainState tx -> Maybe (OnChainTx tx)) -> m () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This suggests that the ChainState tx
may evolve separately from the an event occurrence. Is that the case 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I missed the parentheses. The ChainState
here would be provided by the logic layer. I wonder though if this can be achieved in a pure fashion 🤔 ... Intuitively, I feel like we'd need something like m (ChainState tx)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is the core bit of the whole proposal, i did twiddle things around a bit and tested them on the https://github.com/input-output-hk/hydra-poc/compare/ch1bo/adr-18-single-state-example branch. Happy to walk you through the current proposed state and we can pair on making it simpler still maybe? :)
```hs | ||
postTx :: MonadThrow m => ChainState tx -> PostChainTx tx -> m () | ||
type ChainCallback tx m = (ChainState tx -> Maybe (OnChainTx tx, ChainState tx)) -> m () | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do highly prefer the alternative here ☝️ , as it:
- Keep the base types "simpler"
- Make more obvious from the type signature what is going on (typical state update
s -> (a, s)
) - Maintain a clearer separation between the stateful part, and the somewhat stateless / deterministic bits which are the chain tx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay to merge provided that we make the current alternative the actual decision.
Co-authored-by: Matthias Benkort <[email protected]>
Co-authored-by: Matthias Benkort <[email protected]>
We decided to favor the non-extended "core types" in the Node/Chain interface as it's more explicit about ChainState updates.
0bf208e
to
d50353e
Compare
Drafted how we could keep a single TVar only by updating the interface between
Hydra.Node
andHydra.Chain
.I tried to exercise (quick'n'dirty and not intending to be merged) this and the to-be-discussed alternative (see ADR) on these branches:
hydra-node
with only some undefinedFixes #257