Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CDEC-509] Remove HasCoreConfiguration and HasConfiguration #3550

Merged
merged 3 commits into from
Sep 13, 2018

Conversation

ruhatch
Copy link
Contributor

@ruhatch ruhatch commented Sep 5, 2018

Description

This is the removal of the final Data.Reflection constraint in core! This PR removes the dbSerializeVersion 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

  • [~] 🐞 Bug fix (non-breaking change which fixes an issue)
  • [~] 🛠 New feature (non-breaking change which adds functionality)
  • [~] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • [~] 🔨 New or improved tests for existing code
  • [~] ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • [~] CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • [~] I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

  1. Connect to the testnet running a node on develop and sync some blocks
  2. Kill the node and then with the same state connect with a node from this PR
  3. Verify that the DB is still read and the syncing continues

Screenshots (if available)

@ruhatch ruhatch force-pushed the ruhatch/CDEC-509 branch 2 times, most recently from f4c6f9a to 689b89e Compare September 6, 2018 16:19
@erikd
Copy link
Member

erikd commented Sep 6, 2018

Probably worth rebasing that against current develop (its 38 commits behiind) to reduce the chances of merge errors when it is merged to develop.

Never mind, looks like I was looking at an old version of the branch.

erikd
erikd previously requested changes Sep 8, 2018
Copy link
Member

@erikd erikd left a 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)
Copy link
Member

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.

Copy link
Member

@erikd erikd Sep 9, 2018

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

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

@ruhatch ruhatch force-pushed the ruhatch/CDEC-509 branch 2 times, most recently from 88e42a2 to e0eaefd Compare September 11, 2018 12:55
@erikd erikd dismissed their stale review September 11, 2018 23:20

Reviewing again

= ( MonadGState m
, HasConfiguration
)
type TxDistrMode m = MonadGState m
Copy link
Member

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.

@erikd
Copy link
Member

erikd commented Sep 12, 2018

Something wend way wrong with the changes to lib/configuration.yam.

Github reports:

14,646 additions, 14,676 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

I suspect the "semantic changes only" version of the diff for that file would be 30 lines. We really need that version :)

erikd
erikd previously requested changes Sep 12, 2018
Copy link
Member

@erikd erikd left a 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.

@ruhatch ruhatch force-pushed the ruhatch/CDEC-509 branch 2 times, most recently from cec8ea1 to c178183 Compare September 12, 2018 10:57
@erikd
Copy link
Member

erikd commented Sep 13, 2018

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.

Copy link
Member

@erikd erikd left a 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 :).

@erikd erikd merged commit 1fb8522 into develop Sep 13, 2018
@erikd erikd deleted the ruhatch/CDEC-509 branch September 13, 2018 06:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants