Skip to content
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

Chain DB: fix iterator bug and add tests #810

Merged
merged 7 commits into from
Jul 23, 2019

Conversation

mrBliss
Copy link
Contributor

@mrBliss mrBliss commented Jul 22, 2019

No description provided.

@mrBliss mrBliss added the consensus issues related to ouroboros-consensus label Jul 22, 2019
@mrBliss mrBliss requested a review from nfrisby July 22, 2019 13:11
@mrBliss mrBliss force-pushed the mrBliss/chaindb-iterator-tests branch from bb0a91a to 240d964 Compare July 22, 2019 14:44
@mrBliss mrBliss force-pushed the mrBliss/chaindb-iterator-tests branch from 240d964 to d0e55f9 Compare July 23, 2019 06:48
mrBliss added 3 commits July 23, 2019 09:00
Instead of relying on the whole ChainDB, rely only on the parts actually
needed. This way, simple mocks of the ImmutableDB and the VolatileDB can be
used to easily test the interesting edge cases.
This mock ImmutableDB will be used for the ChainDB iterator tests.

No mock implementation existed yet (as opposed to the VolatileDB), because the
ImmutableDB API does not mention `STM`, which means that we could provide a
pure implementation of the ImmutableDB to use as the model in the q-s-m tests.
@mrBliss mrBliss force-pushed the mrBliss/chaindb-iterator-tests branch from 2c30f29 to 77cceff Compare July 23, 2019 07:01
@mrBliss mrBliss changed the title Chain DB: initial iterator tests Chain DB: fix iterator bug and add tests Jul 23, 2019
@mrBliss mrBliss marked this pull request as ready for review July 23, 2019 07:02
@mrBliss mrBliss force-pushed the mrBliss/chaindb-iterator-tests branch from 77cceff to 9c11d7f Compare July 23, 2019 07:09
Copy link
Contributor

@nfrisby nfrisby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, once CI is happy.

mrBliss added 4 commits July 23, 2019 16:09
Currently, these are only unit tests. In the future, we will write a generator
and turn them into property tests.
When streaming from both the ImmutableDB and the VolatileDB, we need to know
the switchover point, i.e. the tip of the ImmutableDB.

Previously, we were reading that whole block from disk to figure out its hash,
while we already had the necessary information in memory: the anchor point of
the in-memory chain fragment refers to the tip of the ImmutableDB (see the
invariant of 'cdbChain'). We now take advantage of this information and avoid
one extra block read.
This fixes the bug triggered by the `prop_773_bug` test (see its docstring for
more information) in `Test.Ouroboros.Storage.ChainDB.Iterator`.
@mrBliss mrBliss force-pushed the mrBliss/chaindb-iterator-tests branch from 9c11d7f to 952cfe3 Compare July 23, 2019 14:10
@mrBliss mrBliss merged commit 0e8469e into master Jul 23, 2019
@iohk-bors iohk-bors bot deleted the mrBliss/chaindb-iterator-tests branch July 23, 2019 14:20
mrBliss added a commit that referenced this pull request Jul 26, 2019
PR #797 was recently merged, which no longer compiled after merging with
master because of PR #810.

CI did not signal this because there were no merge conflicts and it never
rebuilt PR #797 against the updated master.

To avoid this in the future, use `bors r+`, which first tries to build the
merged PR (as opposed to the unmerged PR branch) before actually pushing to
master.
@mrBliss mrBliss mentioned this pull request Jul 26, 2019
iohk-bors bot added a commit that referenced this pull request Jul 26, 2019
831: Fix broken master r=nc6 a=mrBliss

PR #797 was recently merged, which no longer compiled after merging with
master because of PR #810.

CI did not signal this because there were no merge conflicts and it never
rebuilt PR #797 against the updated master.

To avoid this in the future, use `bors r+`, which first tries to build the
merged PR (as opposed to the unmerged PR branch) before actually pushing to
master.

Co-authored-by: Thomas Winant <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants