-
Notifications
You must be signed in to change notification settings - Fork 632
[CDEC-509] Remove HasCoreConfiguration and HasConfiguration #3550
Conversation
f4c6f9a
to
689b89e
Compare
Never mind, looks like I was looking at an old version of the branch. |
689b89e
to
fece243
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.
I don't trust the DB code and we don't have any tests to give us some confidence we're not breaking anything. I therefore think its prudent to add tests before making this change,
-- | Version of 'serialize'' function that includes version when serializing a value. | ||
dbSerializeValue :: (HasCoreConfiguration, Bi a) => a -> ByteString | ||
dbSerializeValue = serialize' . (dbSerializeVersion,) | ||
dbPutBi tag k v = dbPut tag k (serialize' v) |
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.
Hmm, want to check that a little more carefully on Monday.
Marking this "requires changes" until I properly examine the consequences of 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.
The weird thing is that from looking at the code, I expect this to break when accessing existing DBs. The fact that it doesn't freaks me out even more than if it did break.
I know its a pain in the neck, but we can we separate out the dbSerializeVersion
parts of this PR and add a test to show that its safe. The idea would be to:
- Raise a PR with some tests that use
dbSerializeVersion
as it is now. - Once that PR is merged, raise a PR removing
dbSerializeVersion
.
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.
You're right, that's safer and will reduce the complexity of this PR. I'm getting on it now.
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 changes the DB to write without a version, but read using:
dbDecodeIgnoreVersion :: forall v . Bi v => ByteString -> Either DBError v
dbDecodeIgnoreVersion bytes = case decodeFull' @v bytes of
Right val -> Right val
Left _ -> bimap DBMalformed snd $ decodeFull' @(Word8, v) bytes
which first tries to decode without a version and, if that fails, tries again with the version and drops it
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.
That's why it doesn't break on old DBs :)
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 tests are in place and passing. Ready to re-review, paying particular attention to this file
88e42a2
to
e0eaefd
Compare
= ( MonadGState m | ||
, HasConfiguration | ||
) | ||
type TxDistrMode m = MonadGState 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.
Definitely, not worth doing in this PR but later we should go through the code base and killing completely useless type aliases like type X m = Y m
.
Something wend way wrong with the changes to Github reports:
I suspect the "semantic changes only" version of the diff for that file would be 30 lines. We really need that version :) |
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.
Semanitc changes only in lib/configuration.yaml
please :)
Also wondering it it might not be worthwhile keeping the function dbSerializeValue
and defining it as:
dbSerializeValue = serialize'
which would result in a much smaller PR and the inliner should ensure there is zero performance difference.
cec8ea1
to
c178183
Compare
c178183
to
3505160
Compare
I compiled this version and ran it on an existing node DB (already synced to the 69th epoch or mainnet) and it ran fine. I then deleted the the DB to force a full sync and that also seems to be fine and is currently at the 10th epoch. |
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.
Love that the code base has 400 fewer lines after this is merged :).
Description
This is the removal of the final
Data.Reflection
constraint incore
! This PR removes thedbSerializeVersion
configuration parameter, a so far unused value. Could reviewers please check that a node running the code before this commit continues to sync after this commit is applied.Linked issue
CDEC-509
Type of change
Developer checklist
Testing checklist
QA Steps
develop
and sync some blocksScreenshots (if available)