-
Notifications
You must be signed in to change notification settings - Fork 23
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
Delete ConsensusMode
type
#342
Conversation
a23b983
to
8490c1c
Compare
e8a4f9c
to
6ab9918
Compare
2d87f7d
to
e15de45
Compare
, localTxMonitoringClient | ||
:: Maybe (LocalTxMonitorClient txid tx slot m ()) | ||
} | ||
data LocalNodeClientProtocols point tip slot m = LocalNodeClientProtocols |
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 should remain generic because we are now forcing consumers of cardano-api to use our types for block
, tx
, txid
, txerr
and query
. We can instantiate the types we want with type LocalNodeClientProtocolsInIO
.
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.
If these need to be parameterised, then we need to keep these types:
data BlockInMode mode where
BlockInMode
:: CardanoEra era
-> Block era
-> EraInMode era mode
-> BlockInMode mode
data TxInMode mode where
TxInMode :: Tx era -> EraInMode era mode -> TxInMode mode
TxInByronSpecial :: Consensus.GenTx Consensus.ByronBlock
-> EraInMode ByronEra mode -> TxInMode mode
data TxIdInMode mode where
TxIdInMode :: TxId -> EraInMode era mode -> TxIdInMode mode
data TxValidationErrorInMode mode where
TxValidationErrorInMode :: TxValidationError era
-> EraInMode era mode
-> TxValidationErrorInMode mode
TxValidationEraMismatch :: EraMismatch
-> TxValidationErrorInMode mode
data QueryInMode mode result where
QueryCurrentEra
:: QueryInMode mode AnyCardanoEra
QueryInEra
:: EraInMode era mode
-> QueryInEra era result
-> QueryInMode mode (Either EraMismatch result)
QueryEraHistory
:: QueryInMode mode (EraHistory mode)
QuerySystemStart
:: QueryInMode mode SystemStart
QueryChainBlockNo
:: QueryInMode mode (WithOrigin BlockNo)
QueryChainPoint
:: ConsensusMode mode
-> QueryInMode mode ChainPoint
We can still convert EraInMode era mode
to CardanoEra era
so the mode
type parameter disappears however.
It's not clear what the benefit of keeping these type parameters are if we only fix it to one type. Is there a known use 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.
The deleted parameters of LocalNodeClientProtocols
have been restored.
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.
Looking good. One significant comment: https://github.com/input-output-hk/cardano-api/pull/342/files#r1374534246
tx' = Consensus.ByronTx (Consensus.byronIdTx tx) tx | ||
|
||
toConsensusGenTx (TxInMode (ByronTx tx) ByronEraInCardanoMode) = | ||
data TxInMode where |
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 necessary for this PR but we need to think of a better name.
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.
Yep. I kept the name so the diff is easier to see. A separate PR can rename the type.
-- actually transactions. This covers: update proposals, votes and | ||
-- delegation certs. | ||
-- | ||
TxInByronSpecial |
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.
We may be able to get away with using data Tx era
directly and removing TxInMode
. If we can convert Byron.ATxAux ByteString -> Consensus.GenTx Consensus.ByronBlock
then we should be able to. Not necessary for this PR.
|
||
-- | The Shelley-only consensus mode consists of only the Shelley era. | ||
-- | ||
-- This was used for the early Shelley testnets prior to the use of the |
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.
Nice, so my memory served me correctly.
6f81c9a
to
7072909
Compare
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.
Almost there! I spotted an error.
, localTxMonitoringClient | ||
:: Maybe (LocalTxMonitorClient txid tx slot m ()) | ||
} | ||
LocalNodeClientProtocols |
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.
💪
consensusModeOnly ShelleyModeParams{} = ShelleyMode | ||
consensusModeOnly CardanoModeParams{} = CardanoMode | ||
|
||
type LocalNodeClientProtocolsInMode = |
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.
💪
Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (Z tx'))) -> | ||
let Consensus.ShelleyTx _txid shelleyEraTx = tx' | ||
in TxInMode ShelleyEra (ShelleyTx ShelleyBasedEraShelley shelleyEraTx) | ||
Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (Z 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.
Not necessary for this PR but in consensus there are patterns we can use:
pattern TagByron x = Z x
pattern TagShelley x = S (Z x)
pattern TagAllegra x = S (S (Z x))
pattern TagMary x = S (S (S (Z x)))
pattern TagAlonzo x = S (S (S (S (Z x))))
pattern TagBabbage x = S (S (S (S (S (Z x)))))
pattern TagConway x = S (S (S (S (S (S (Z x))))))
ConsensusBlockForEra, | ||
EraInMode(..), |
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.
💪
@@ -47,10 +47,6 @@ module Cardano.Api.Byron | |||
|
|||
-- ** Low level protocol interaction with a Cardano node | |||
LocalNodeConnectInfo(LocalNodeConnectInfo), | |||
ByronMode, |
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.
👍
* convLocalChainSyncClient * convLocalChainSyncClientPipelined * convLocalNodeClientProtocols * convLocalTxMonitoringClient * fromConsensusGenTx * fromConsensusTip
7072909
to
b155e2d
Compare
Changelog
Context
We neither use not need
ConsensusMode
anymore.This PR makes all the necessary changes to remove
ConsensusMode
.Type names and function names retain the word
Mode
in them because that can be postponed to a future PR.Refactoring to simplify code enabled by the removal can also be postponed to a future PR.
How to trust this PR
Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.
Checklist