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(ledger): backward merkle root chaining bugs #347

Merged
merged 7 commits into from
Nov 4, 2024

Conversation

dnut
Copy link
Contributor

@dnut dnut commented Oct 31, 2024

bug fixes

Previously, backwards merkle root chaining checks were:

  • ignoring the actual result of the check
    • always marked it as a duplicate (as if the check failed)
    • always returned true (as if the check succeeded)
  • comparing chained root to chained root, which is wrong. it should be chained to actual root

refactoring

consolidate common chaining logic into single function "checkAndReportChaining"

Improve dependency management by:

  • organizing merkle root check functions into a struct since they all share some common dependencies. this simplifies the function signatures and keeps things standardized and consistent
  • utilizing working stores.
    • this is better than passing down the granular transitive dependencies (database and hashmap) separately because it clarifies what this code actually needs. all it really needs is some kind of store for erasure metas. it's not actually important in this context that it's managed through a negotiation between database and hashmap calls. this is the whole point of the pending state, to abstract away that negotiation. passing down all the transitive dependencies makes the function parameters a mess, and it becomes unclear why the code actually needs any of the dependencies.
    • this is better than passing down the whole pending state struct because it reduces the number of dependencies and it clarifies what is actually needed, rather than pretending the entire state is needed.

change in behavior

merkle root checks now return an error if the merkle root is missing, instead of ignoring it, because that means there is a severe bug in the validator and it needs to be shutdown and patched immediately.

@dnut dnut requested a review from dadepo October 31, 2024 16:54
@dnut dnut force-pushed the dnut/fix/backward-merkle-chaining branch from 7723311 to e93d7e1 Compare October 31, 2024 18:09
dnut and others added 6 commits October 31, 2024 17:39
It was ignoring result of checking chaining, and just always marked it as a duplicate (as if the check failed), and always returned true (as if the check succeeded). complete nonsense

It was comparing chained root to chained root, which is wrong. it should be chained to actual root

This change also refactors common logic into a single place.

Also this now returns an error if the merkle root is missing, because that means there is a severe bug in the validator and it needs to be shutdown and patched immediately.
Co-authored-by: InKryption <59504965+InKryption@users.noreply.github.com>
the four methods all have basically the same dependencies so this bundles them together to clarify their purpose and simplify their expression
@dnut dnut force-pushed the dnut/fix/backward-merkle-chaining branch from e827130 to 918d188 Compare October 31, 2024 21:39
@dnut dnut self-assigned this Oct 31, 2024
@dnut dnut enabled auto-merge (squash) November 4, 2024 14:18
@dnut dnut merged commit 988fe6e into main Nov 4, 2024
6 checks passed
@dnut dnut deleted the dnut/fix/backward-merkle-chaining branch November 4, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants