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

Codify database invariants #4878

Open
michaelsproul opened this issue Oct 25, 2023 · 1 comment
Open

Codify database invariants #4878

michaelsproul opened this issue Oct 25, 2023 · 1 comment
Assignees
Labels
code-quality database major-task A significant amount of work or conceptual task.

Comments

@michaelsproul
Copy link
Member

Description

There are several invariants maintained by the database which are not currently documented anywhere other than in comments and code. To improve this I think we should add a set of invariants that are:

  • Executable
  • Documented

These can then be used in a tool like lighthouse db check-invariants, in tests, and in periodic background tasks on some of our infrastructure.

I think it might be good to describe each invariant in a struct like:

Invariant {
   name: "freezer_block_roots",
   description: "Every slot from oldest_block_slot to the split slot should have a block root",
   speed: InvariantSpeed::Fast,
   check: |db| db.iter_column(DBColumn::BeaconBlockRoots).for_each(...),
}

Version

Lighthouse v4.5.0

Additional Info

Would hopefully help catch issues like #4697 earlier in the development cycle.

@michaelsproul michaelsproul added major-task A significant amount of work or conceptual task. code-quality database labels Oct 25, 2023
@michaelsproul michaelsproul self-assigned this Oct 25, 2023
@michaelsproul
Copy link
Member Author

Assigning this to myself because I've probably got the most DB invariant context, but I'm not making a firm commitment to work on this immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality database major-task A significant amount of work or conceptual task.
Projects
None yet
Development

No branches or pull requests

1 participant