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

Fix maintenance of ledger state #413

Merged
merged 4 commits into from
Nov 22, 2020
Merged

Fix maintenance of ledger state #413

merged 4 commits into from
Nov 22, 2020

Conversation

erikd
Copy link
Contributor

@erikd erikd commented Nov 22, 2020

No description provided.

Mainly for debugging. When this aborts the program, it can leave the
database in a werid state.
Maintenance of ledger state uses code in the consensus packages as a library.

* There are two versions of a function to apply a block to a ledger state; a
  slow one that does full checking and fast one that does fewer checks.
* Since db-sync is getting blocks that have already been validated by the node,
  it seemed sensible to use the fast version.
* I had been told that the checks in the fast version included checking that the
  block's previous hash matches the value of the head hash in the ledger state,
  but this hash check was not being done.

The previous lack of hash checking means the problem was not detected until the
start of the next epoch.
When blocks and rollback notifications arrive via the chainsync protocol,
they are put in a queue and then a separate thread reads from the queue and
operates on the DB. When ledger-state management was added, code to apply a
block to a ledger state was added at the read end of the queue, but the
rollback handling was incorrectly added at the write end of the queue.

The solution to the problem is trivial, move the ledger state rollback
handling from the write end of the queue to the read end.

Closes: https://github.com/input-output-hk/cardano-db-sync/issue/398
@erikd erikd merged commit ec6b662 into master Nov 22, 2020
@iohk-bors iohk-bors bot deleted the erikd/new-epoch-failure branch November 22, 2020 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant