-
Notifications
You must be signed in to change notification settings - Fork 158
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
CAD-2000: Make the protocol era-independent #1915
Conversation
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.
Fantastic! I have been propagating Jared's branch to consensus and now everything fits nicely together 🙂
There are two problems, though (copying them from #1902). For the first one, see the inline comment about chainChecks
. The second one:
We have the following class in consensus:
class ( Crypto c
, SL.DSignable c (OCertSignable c)
-- , SL.DSignable c (Hash c (TxBody era)) TODO
, SL.KESignable c (BHBody c)
, SL.VRFSignable c Seed
) => TPraosCrypto c
It would be a lot more convenient if that era
wasn't there 🙂.
Maybe we can do something similar to what you did for the block body? I.e.:
newtype HashBBody crypto = UnsafeHashBBody {unHashBody :: (Hash crypto EraIndependentBodyHash)}
Alternatively, adding SL.DSignable (EraCrypto era) (Hash (EraCrypto era) (TxBody era))
to ShelleyBased
would also well.
@@ -52,7 +52,7 @@ chainChecks :: | |||
) => | |||
Globals -> | |||
PParams era -> |
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 needs access to the PParams
when calling chainChecks
. Before this PR, we could extract them from the LedgerView
, but that's no longer possible with this PR. Consensus doesn't have anything else in scope where it could get the PParams
from.
Potential solution: create a record with the fields needed by chainChecks
(_maxBHSize
, _maxBBSize
, _protocolVersion
), let chainChecks
that record as an argument and store the record in the LedgerView
.
(Without a fix, the integration in consensus is broken.)
@@ -245,25 +251,52 @@ instance | |||
initialRules = [] | |||
transitionRules = [chainTransition] | |||
|
|||
data ChainChecksData = ChainChecksData |
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'm open to help naming this thing...
0c1c9af
to
b505135
Compare
@mrBliss I've added two commits, one for each of the problems you mentioned. The second commit still has failing tests (I'm having a problem where
|
@JaredCorduan Thanks! I'll try them out in consensus later today. |
|
||
instance Era era => FromCBOR (LedgerView era) where | ||
instance CC.Crypto crypto => FromCBOR (LedgerView crypto) 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.
BTW, consensus doesn't need to (de)serialise LedgerView
anymore, so you can get rid of these instances (and the ones for ChainChecksData
too).
Thanks for the fixes for the two issues I brought up, I have verified that they work out well in consensus 👍. As mentioned, I would remove the |
0093810
to
2a5cf4d
Compare
2a5cf4d
to
117f199
Compare
There was a quickcheck failure:
I am fairly certain that it is unrelated to this PR (our trace generators have somehow generated a negative coin). I think it makes sense to note the failure (we have the seed now) and rerun the tests. |
instance CC.Crypto crypto => FromCBOR (ChainDepState crypto) where | ||
fromCBOR = | ||
decodeRecordNamed | ||
"ChainDepState" | ||
(const 3) | ||
( ChainDepState | ||
<$> fromCBOR | ||
<*> fromCBOR | ||
<*> fromCBOR | ||
) | ||
|
||
instance CC.Crypto crypto => ToCBOR (ChainDepState crypto) where | ||
toCBOR | ||
ChainDepState | ||
{ csProtocol, | ||
csTickn, | ||
csLabNonce | ||
} = | ||
mconcat | ||
[ encodeListLen 3, | ||
toCBOR csProtocol, | ||
toCBOR csTickn, | ||
toCBOR csLabNonce | ||
] | ||
|
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.
Oh, not this, we still need this 🙂
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 will resurrect it! 🧟♂️
instance ToCBOR ChainChecksData where | ||
toCBOR (ChainChecksData bhs bbs pv) = | ||
encodeListLen 3 <> toCBOR bhs <> toCBOR bbs <> toCBOR pv | ||
|
||
instance FromCBOR ChainChecksData where | ||
fromCBOR = do | ||
decodeRecordNamed "ChainChecksData" (const 3) $ do | ||
bhs <- fromCBOR | ||
bbs <- fromCBOR | ||
pv <- fromCBOR | ||
pure $ ChainChecksData bhs bbs pv |
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 can be removed, though.
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.
oh goodness, yes, I mistook ChainDepState
for ChainChecksData
. thank you @mrBliss !
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.
ok, we are now only removing LedgerView
from API/Protocol.hs
, and the CBOR instances for ChainChecksData
are removed from the commit that introduced them.
117f199
to
b3e74c8
Compare
2702: Update dependencies r=mrBliss a=mrBliss Highlights: * IntersectMBO/cardano-ledger#1915 * IntersectMBO/cardano-ledger#1922 * IntersectMBO/cardano-ledger#1902 * IntersectMBO/cardano-ledger#1923 * IntersectMBO/cardano-ledger#1927 * IntersectMBO/cardano-ledger#1929 Co-authored-by: Thomas Winant <thomas@well-typed.com>
Addresses https://jira.iohk.io/browse/CAD-2000
There are some additional comments in #1902 which may need to be addressed before merging.