-
Notifications
You must be signed in to change notification settings - Fork 213
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
[ADP-3344] Add TimeInterpreter
to Cardano.Wallet.Deposit.Write
#4816
base: master
Are you sure you want to change the base?
[ADP-3344] Add TimeInterpreter
to Cardano.Wallet.Deposit.Write
#4816
Conversation
12adff0
to
33b9b08
Compare
33b9b08
to
99bd214
Compare
@@ -60,6 +60,7 @@ library | |||
, cardano-strict-containers | |||
, cardano-wallet | |||
, cardano-wallet-network-layer | |||
, cardano-wallet-primitive |
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.
Can you avoid this pls. Do we need the Interpreter or just some functions in 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.
Not happy about it either, but I want the TimeInterpreter
— it's reasonably well-designed. 🤔 One of the next steps would be to split off the TimeInterpreter
into a separate package and get rid of the dependency on -primitive
again.
(And also remove the m
parameter of the TimeInterpreter
, it's more hassle than benefit.)
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.
From the perspective of createPayment
or a deposit wallet specific balanceTx wrapper I suspect you might ideally want to hide both PParams
and TimeTranslation
inside some single LocalNodeTipStateForTxWrite
. Both for the sake of hiding the details, but also for the sake of querying it atomically from the node. But the read side will need the TimeInterpreter
, or similar, too.
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.
also for the sake of querying it atomically from the node
For the deposit wallet this would probably not matter (balanceTx only uses the TimeTranslation to evaluate execution units, and we don't have any UTxO or deposit lookups). In general, perhaps we still deem it not to matter, but it does lead to code like
cardano-wallet/lib/wallet/src/Cardano/Wallet.hs
Lines 2226 to 2242 in aa7fe8c
-- Assumes the 'utxo' was queried from the node /after/ the 'era'. As | |
-- rolling back to a previous era should be impossible, we know 'IsRecentEra | |
-- era => IsRecentEra eraOfUTxO'. | |
forceUTxOToEra | |
:: Write.MaybeInRecentEra Write.UTxO | |
-> IO (Write.UTxO era) | |
forceUTxOToEra = \case | |
InRecentEraConway utxo -> hoist $ Write.forceUTxOToEra utxo | |
InRecentEraBabbage utxo -> hoist $ Write.forceUTxOToEra utxo | |
InNonRecentEraAlonzo -> impossibleRollback | |
InNonRecentEraMary -> impossibleRollback | |
InNonRecentEraAllegra -> impossibleRollback | |
InNonRecentEraShelley -> impossibleRollback | |
InNonRecentEraByron -> impossibleRollback | |
where | |
impossibleRollback = error "forceUTxOToEra: era should not roll back" | |
hoist = either (throwIO . ExceptionInvalidTxOutInEra) pure |
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 have no problem with the m
as long as it's the way to get a pure functions out of it that we can reuse during atomic operations like ingesting a block or translating time in the tx history.
But I would prefer to enumerate the exact functions we need out of it in the interface and leave the implementations of those to later. That would make mocking easier and avoid implementation leaks
This pull request imports the
TimeInterpreter
type inCardano.Wallet.Deposit.Write
and adds it to theNetworkEnv
.Comments
balanceTx
increatePayment
Cardano.Wallet.Deposit.Write
is a temporary location for the re-export, until we separate out theTimeInterpreter
-related stuff into a separate library.Issue Number
ADP-3344