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

Validation of the VolatileDB #1568

Merged
merged 3 commits into from Feb 13, 2020
Merged

Validation of the VolatileDB #1568

merged 3 commits into from Feb 13, 2020

Conversation

kderme
Copy link
Contributor

@kderme kderme commented Feb 4, 2020

Addresses part 2 of #1304 (comment) and more:

  • there is an option to check if each parsed block is valid, while parsing.
  • the db now recovers when there is a duplicated slot and ignores invalid filenames.
  • added tests for this.
  • added traces.

readIncrementalOffsets is no longer used anywhere. Worth keeping?

@kderme kderme added WIP Do not merge, work in progress. consensus issues related to ouroboros-consensus chain db volatile db priority high and removed priority high chain db volatile db labels Feb 4, 2020
@kderme kderme force-pushed the kderme/validate_volatile_db branch 2 times, most recently from 4632ec2 to 0ecc3f1 Compare February 6, 2020 10:31
@kderme kderme removed the WIP Do not merge, work in progress. label Feb 6, 2020
Comment on lines 432 to 433
tryCollectFile hasFS env@VolatileDBEnv{..} slot st@InternalState{..}
(fileId, fileInfo) =
Copy link
Contributor

Choose a reason for hiding this comment

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

I would revert this change (so it's one line again) and use the following instead:

tryCollectFile ...
    ....
  where
    VolatileDBEnv { _dbErr, _tracer } = env

Copy link
Contributor Author

@kderme kderme Feb 6, 2020

Choose a reason for hiding this comment

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

This is not so easy because VolatileDBEnv is Existential type, but I did the same for InternalState to keep it a single line.

Comment on lines 641 to 616
checkBlockIntegrity :: TestBlock -> Bool
checkBlockIntegrity testBlock =
hashHeader (testHeader testBlock) == thHash (testHeader testBlock)
|| not (tbIsValid (testBody testBlock))

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this the same as Test.Ouroboros.Storage.TestBlock.testBlockIsValid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost yes, this also checkes tbIsValid

@kderme kderme force-pushed the kderme/validate_volatile_db branch 2 times, most recently from 8784596 to f04ff48 Compare February 6, 2020 13:39
@kderme kderme force-pushed the kderme/validate_volatile_db branch 6 times, most recently from 1abf132 to 4b1e9eb Compare February 12, 2020 13:33
@mrBliss
Copy link
Contributor

mrBliss commented Feb 13, 2020

This ready for merging. Thanks @kderme for the validation code. I cleaned up some bits and implemented part 1 of #1304 (comment).

@mrBliss
Copy link
Contributor

mrBliss commented Feb 13, 2020

bors r+

@mrBliss mrBliss linked an issue Feb 13, 2020 that may be closed by this pull request
iohk-bors bot added a commit that referenced this pull request Feb 13, 2020
1568: Validation of the VolatileDB r=mrBliss a=kderme

Addresses part 2 of #1304 (comment) and more:

- there is an option to check if each parsed block is valid, while parsing.
- the db now recovers when there is a duplicated slot and ignores invalid filenames.
- added tests for this.
- added traces.

`readIncrementalOffsets` is no longer used anywhere. Worth keeping?

1640: demo chain sync -- cli args r=coot a=coot



Co-authored-by: kderme <k.dermenz@gmail.com>
Co-authored-by: Thomas Winant <thomas@well-typed.com>
Co-authored-by: Marcin Szamotulski <profunctor@pm.me>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 13, 2020

This PR was included in a batch that timed out, it will be automatically retried

iohk-bors bot added a commit that referenced this pull request Feb 13, 2020
1568: Validation of the VolatileDB r=mrBliss a=kderme

Addresses part 2 of #1304 (comment) and more:

- there is an option to check if each parsed block is valid, while parsing.
- the db now recovers when there is a duplicated slot and ignores invalid filenames.
- added tests for this.
- added traces.

`readIncrementalOffsets` is no longer used anywhere. Worth keeping?

Co-authored-by: kderme <k.dermenz@gmail.com>
Co-authored-by: Thomas Winant <thomas@well-typed.com>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 13, 2020

@iohk-bors iohk-bors bot merged commit 6b60de3 into master Feb 13, 2020
@iohk-bors iohk-bors bot deleted the kderme/validate_volatile_db branch February 13, 2020 14:48
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.

Check block validity when copying from VolatileDB to ImmutableDB
2 participants