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

Implements #11616 - EIP-3076 - Minimal database #12475

Closed
wants to merge 8 commits into from
Closed

Implements #11616 - EIP-3076 - Minimal database #12475

wants to merge 8 commits into from

Conversation

nalepae
Copy link
Contributor

@nalepae nalepae commented May 29, 2023

This PR is easier to review commit by commit. (Useful information are in commit message description)

What type of PR is this?
Feature

What does this PR do? Why is it needed?
This PR implements the minimal slashing protection database, as specified in EIP-3076.

  • signed_attestations:

    • During validator runtime
    • During JSON import
    • During JSON export
  • signed_blocks:

    • During validator runtime
    • During JSON import
    • During JSON export
  • Tests

In term of data, the minimal slashing database can be seen as a subset of the complete slashing database, as it has the exact same schema, but contains only the block with the maximum slot and attestations with the maximum source and target for each validator.

=> There is no need to have a database interface and 2 implementations of this interface (complete and minimal), since the minimal database can be simply handled by removing, for each validator, all but the latest message (atomically with the new insertion).

A new --enable-minimal-slashing-protection-database flag is defined in the validator client.

Design choices about complete/minimal interoperability:

  1. The validator client cannot start if the --enable-minimal-slashing-protection-database flag is set while a pre-existing complete database is found. (The opposite is possible).
  2. The validator client can import a complete JSON interchange file into a minimal database. However, only block with the maximum slot and attestations with the maximum source and target for each validator will be imported in the minimal database. (By design, it's also possible to import a minimal JSON interchange file into a complete database, since the JSON interchange file with a list of signed_blocks or signed_attestations with only 1 element can be both considered as a minimal JSON interchange file or as a complete JSON interchange file, but with only 1 attestation/block per validator.)

Because of 1., Prysm validator client should provide a tool to convert a complete database to a minimal one.
Example:

prysm.sh validator slashing-protection-history convert-to-minimal

Notes about the current antislashing database:

"pubkeys-bucket"  -> <pubkey> -> "att-signing-roots-bucket" -> <target epoch> -> <signing root>
                              |
                              -> "att-source-epoch-bucket"  -> <source epoch> -> []<target epoch>
                              |
                              -> "att-target-epoch-bucket"  -> <target epoch> -> []<source epoch>

"lowest-signed-source-bucket" -> <pubkey> -> <lowest signed source epoch>
"lowest-signed-target-bucket  -> <pubkey> -> <lowest signed target epoch>

EIP-3076 condition 3 (attestation slashing rules):

Same source, different target ==> ✅

old attestation: S ----------------> T (whatever the signing root is)
new attestation: S -----------> T (whatever the signing root is)

or

old attestation: S -------------> T (whatever the signing root is)
new attestation: S ------> T (whatever the signing root is)

Same source, same target, same root ==> ✅

old attestation: S ----------------> T (signing root A)
new attestation: S ----------------> T (signing root A)

Same source, same target, different root ==> ❌ (LMD Ghost and/or Casper FFG violation)

old attestation: S ----------------> T (signing root A)
new attestation: S ----------------> T (signing root B)

Different source, same target ==> ❌ (LMD Ghost and/or Casper FFG violation)

old attestation:      S -----------> T (whatever the root is)
new attestation: S ----------------> T (whatever the root is)

Surrounding ==> ❌ (Casper FFG violation)

old attestation:      S -----> T (whatever the signing root is)
new attestation: S ----------------> T (whatever the signing root is)

Surrounded ==> ❌ (Casper FFG violation)

old attestation: S ----------------> T (whatever the signing root is)
new attestation:      S -----> T (whatever the signing root is)

Which issues(s) does this PR fix?
Fixes #11616

nalepae added 8 commits May 29, 2023 23:56
…ing`

This test function tests more functions than `Uint64FromString`.
The function `NewKVStore` creates, via `kv.UpdatePublicKeysBuckets`,
a new item in the `proposal-history-bucket-interchange`.

IMO there is no real reason to prefer `proposal` than `attestation`
as a prefix for this bucket, but this is the way it is done right now
and renaming the bucket will probably will backward incompatible.

An `attestedPublicKey` cannot exist without
the corresponding `proposedPublicKey`.

Thus, the `else` portion of code removed in this commit is not reachable.
We raise an error if we get there.

This is also probably the reason why the removed `else` portion was not
tested.
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.

Implement minimal slashing DB
1 participant