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

Opt-in Slashing protection + interchange #1643

Merged
merged 13 commits into from
Sep 16, 2020
Merged

Opt-in Slashing protection + interchange #1643

merged 13 commits into from
Sep 16, 2020

Conversation

mratsim
Copy link
Contributor

@mratsim mratsim commented Sep 14, 2020

This adds slashing protection to the Beacon Node and validator client

State

  • Slashing protection engine
    • Slashing protection for duplicate block proposal slots
    • Slashing protection for duplicate attestation target epochs
    • Slashing protection for surrounding votes
    • Slashing protection for surrounded votes
    • Optional DB pruning (incompatible with "complete" export)
  • Integration in Beacon Node and Validator Client
    • Block proposal
    • Attestation
  • Interchange
    • "Complete" format export
    • "minimal" format export
    • "Complete" format import
    • "minimal" format import
  • Optimization
    • Avoid duplicate compute_block_root / compute_attestation_root

Overview

The slashing protection is introduced as an experimental feature that can be opt-in with
make NIMFLAGS="-d:UseSlashingProtection=true" beacon_node or make NIMFLAGS="-d:UseSlashingProtection=true" validator_client
For now only block proposal are protected, protecting attestation requires to add registerAttestation and notSlashableAttestation in their proper place in validator_duties.nim and validator_client.nim

Interchange

Complete export can be done by calling "toSPDIF" on the slashing protection database, likely to be added to ncli_db.

Design

The slashing protection uses an independent database that is attached to either the Beacon Node or the Validator Client. It's a KV-Store but a classic SQL DB would significantly reduce the potential bug surface as right now I'm using a linked list in the DB field which accounts for a lot of lines of code. Alternatively, better support for range queries for the KV-Store would be nice

@mratsim mratsim changed the title Slashing protection + interchange initial commit [WIP] Opt-in Slashing protection + interchange Sep 14, 2020
@mratsim mratsim marked this pull request as draft September 14, 2020 11:38
beacon_chain.nimble Outdated Show resolved Hide resolved
@mratsim mratsim marked this pull request as ready for review September 15, 2020 14:26
@mratsim
Copy link
Contributor Author

mratsim commented Sep 15, 2020

Not draft anymore.

I've added an extra temporary test with/without slashing protection for jenkins

  • make sure that without slashing protection, we don't access the DB and so no null pointer exception
  • make sure that we finalized with slashing protection instead of being stuck in a endless loop
    Once that succeed we'll only keep slashing protection in Jenkins (as tests are long)

Regarding import/export AFAIK no one actually supports them yet in production code (but does in PR) so no real rush but importing a complete DB is straightforward. Adding that in this PR.

@mratsim mratsim changed the title [WIP] Opt-in Slashing protection + interchange Opt-in Slashing protection + interchange Sep 16, 2020
beacon_chain/validator_client.nim Outdated Show resolved Hide resolved
beacon_chain/validator_slashing_protection.nim Outdated Show resolved Hide resolved
@mratsim mratsim merged commit 52548f0 into devel Sep 16, 2020
@mratsim mratsim deleted the slashing-prot branch September 16, 2020 11:30
mratsim added a commit that referenced this pull request Sep 16, 2020
* Slashing protection + interchange initial commit

* Restrict the when UseSlashingProtection dance in other modules

* Integrate slashing tests in other all_tests

* Add attestation slashing protection support

* Add a message that mention if built with/without slashing protection

* no op the initialization proc

* test slashing protection in Jenkins (temp)

* where to configure NIMFLAGS in Jenkins ...

* Jenkins -> ensure Built with slashing protection

* Add slashing protection complete import

* use Opt.get(otherwise)

* Don't use negation in proc name

* Turn slashing protection on by default
mratsim added a commit that referenced this pull request Sep 16, 2020
* Slashing protection + interchange initial commit

* Restrict the when UseSlashingProtection dance in other modules

* Integrate slashing tests in other all_tests

* Add attestation slashing protection support

* Add a message that mention if built with/without slashing protection

* no op the initialization proc

* test slashing protection in Jenkins (temp)

* where to configure NIMFLAGS in Jenkins ...

* Jenkins -> ensure Built with slashing protection

* Add slashing protection complete import

* use Opt.get(otherwise)

* Don't use negation in proc name

* Turn slashing protection on by default
mratsim added a commit that referenced this pull request Sep 16, 2020
* Slashing protection + interchange initial commit

* Restrict the when UseSlashingProtection dance in other modules

* Integrate slashing tests in other all_tests

* Add attestation slashing protection support

* Add a message that mention if built with/without slashing protection

* no op the initialization proc

* test slashing protection in Jenkins (temp)

* where to configure NIMFLAGS in Jenkins ...

* Jenkins -> ensure Built with slashing protection

* Add slashing protection complete import

* use Opt.get(otherwise)

* Don't use negation in proc name

* Turn slashing protection on by default
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.

2 participants