Go to file
Manu NALEPA ef21d3adf8
Implement EIP-3076 minimal slashing protection, using a filesystem database (#13360)
* `EpochFromString`: Use already defined `Uint64FromString` function.

* `Test_uint64FromString` => `Test_FromString`

This test function tests more functions than `Uint64FromString`.

* Slashing protection history: Remove unreachable code.

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 be 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.

* `NewKVStore`: Switch items in `createBuckets`.

So the order corresponds to `schema.go`

* `slashableAttestationCheck`: Fix comments and logs.

* `ValidatorClient.db`: Use `iface.ValidatorDB`.

* BoltDB database: Implement `GraffitiFileHash`.

* Filesystem database: Creates `db.go`.

This file defines the following structs:
- `Store`
- `Graffiti`
- `Configuration`
- `ValidatorSlashingProtection`

This files implements the following public functions:
- `NewStore`
- `Close`
- `Backup`
- `DatabasePath`
- `ClearDB`
- `UpdatePublicKeysBuckets`

This files implements the following private functions:
- `slashingProtectionDirPath`
- `configurationFilePath`
- `configuration`
- `saveConfiguration`
- `validatorSlashingProtection`
- `saveValidatorSlashingProtection`
- `publicKeys`

* Filesystem database: Creates `genesis.go`.

This file defines the following public functions:
- `GenesisValidatorsRoot`
- `SaveGenesisValidatorsRoot`

* Filesystem database: Creates `graffiti.go`.

This file defines the following public functions:
- `SaveGraffitiOrderedIndex`
- `GraffitiOrderedIndex`

* Filesystem database: Creates `migration.go`.

This file defines the following public functions:
- `RunUpMigrations`
- `RunDownMigrations`

* Filesystem database: Creates proposer_settings.go.

This file defines the following public functions:
- `ProposerSettings`
- `ProposerSettingsExists`
- `SaveProposerSettings`

* Filesystem database: Creates `attester_protection.go`.

This file defines the following public functions:
- `EIPImportBlacklistedPublicKeys`
- `SaveEIPImportBlacklistedPublicKeys`
- `SigningRootAtTargetEpoch`
- `LowestSignedTargetEpoch`
- `LowestSignedSourceEpoch`
- `AttestedPublicKeys`
- `CheckSlashableAttestation`
- `SaveAttestationForPubKey`
- `SaveAttestationsForPubKey`
- `AttestationHistoryForPubKey`

* Filesystem database: Creates `proposer_protection.go`.

This file defines the following public functions:
- `HighestSignedProposal`
- `LowestSignedProposal`
- `ProposalHistoryForPubKey`
- `ProposalHistoryForSlot`
- `ProposedPublicKeys`

* Ensure that the filesystem store implements the `ValidatorDB` interface.

* `slashableAttestationCheck`: Check the database type.

* `slashableProposalCheck`: Check the database type.

* `slashableAttestationCheck`: Allow usage of minimal slashing protection.

* `slashableProposalCheck`: Allow usage of minimal slashing protection.

* `ImportStandardProtectionJSON`: Check the database type.

* `ImportStandardProtectionJSON`: Allow usage of min slashing protection.

* Implement `RecursiveDirFind`.

* Implement minimal<->complete DB conversion.

3 public functions are implemented:
- `IsCompleteDatabaseExisting`
- `IsMinimalDatabaseExisting`
- `ConvertDatabase`

* `setupDB`: Add `isSlashingProtectionMinimal` argument.

The feature addition is located in `validator/node/node_test.go`.
The rest of this commit consists in minimal slashing protection testing.

* `setupWithKey`: Add `isSlashingProtectionMinimal` argument.

The feature addition is located in `validator/client/propose_test.go`.

The rest of this commit consists in tests wrapping.

* `setup`: Add `isSlashingProtectionMinimal` argument.

The added feature is located in the `validator/client/propose_test.go`
file.

The rest of this commit consists in tests wrapping.

* `initializeFromCLI` and `initializeForWeb`: Factorize db init.

* Add `convert-complete-to-minimal` command.

* Creates `--enable-minimal-slashing-protection` flag.

* `importSlashingProtectionJSON`: Check database type.

* `exportSlashingProtectionJSON`: Check database type.

* `TestClearDB`: Test with minimal slashing protection.

* KeyManager: Test with minimal slashing protection.

* RPC: KeyManager: Test with minimal slashing protection.

* `convert-complete-to-minimal`: Change option names.

Options were:
- `--source` (for source data directory), and
- `--target` (for target data directory)

However, since this command deals with slashing protection, which has
source (epochs) and target (epochs), the initial option names may confuse
the user.

In this commit:
`--source` ==> `--source-data-dir`
`--target` ==> `--target-data-dir`

* Set `SlashableAttestationCheck` as an iface method.

And delete `CheckSlashableAttestation` from iface.

* Move helpers functions in a more general directory.

No functional change.

* Extract common structs out of `kv`.

==> `filesystem` does not depend anymore on `kv`.
==> `iface` does not depend anymore on `kv`.
==> `slashing-protection` does not depend anymore on `kv`.

* Move `ValidateMetadata` in `validator/helpers`.

* `ValidateMetadata`: Test with mock.

This way, we can:
- Avoid any circular import for tests.
- Implement once for all `iface.ValidatorDB` implementations
  the `ValidateMetadata`function.
- Have tests (and coverage) of `ValidateMetadata`in
  its own package.

The ideal solution would have been to implement `ValidateMetadata` as
a method with the `iface.ValidatorDB`receiver.
Unfortunately, golang does not allow that.

* `iface.ValidatorDB`: Implement ImportStandardProtectionJSON.

The whole purpose of this commit is to avoid the `switch validatorDB.(type)`
in `ImportStandardProtectionJSON`.

* `iface.ValidatorDB`: Implement `SlashableProposalCheck`.

* Remove now useless `slashableProposalCheck`.

* Delete useless `ImportStandardProtectionJSON`.

* `file.Exists`: Detect directories and return an error.

Before, `Exists` was only able to detect if a file exists.
Now, this function takes an extra `File` or `Directory` argument.
It detects either if a file or a directory exists.

Before, if an error was returned by `os.Stat`, the the file was
considered as non existing.
Now, it is treated as a real error.

* Replace `os.Stat` by `file.Exists`.

* Remove `Is{Complete,Minimal}DatabaseExisting`.

* `publicKeys`: Add log if unexpected file found.

* Move `{Source,Target}DataDirFlag`in `db.go`.

* `failedAttLocalProtectionErr`: `var`==> `const`

* `signingRoot`: `32`==> `fieldparams.RootLength`.

* `validatorClientData`==> `validator-client-data`.

To be consistent with `slashing-protection`.

* Add progress bars for `import` and `convert`.

* `parseBlocksForUniquePublicKeys`: Move in `db/kv`.

* helpers: Remove unused `initializeProgressBar` function.
2024-03-05 15:27:15 +00:00
.github Update Libp2p To v0.32.1 and Go to v1.21.5 (#13304) 2023-12-21 16:09:54 +00:00
.well-known Update security.txt (#9896) 2021-11-12 15:55:45 +00:00
api Unify log fields (#13654) 2024-02-22 22:40:36 +00:00
async Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
beacon-chain Implement EIP-3076 minimal slashing protection, using a filesystem database (#13360) 2024-03-05 15:27:15 +00:00
build Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
cache Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
cmd Implement EIP-3076 minimal slashing protection, using a filesystem database (#13360) 2024-03-05 15:27:15 +00:00
config Implement EIP-3076 minimal slashing protection, using a filesystem database (#13360) 2024-03-05 15:27:15 +00:00
consensus-types Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
container Optimize Adding Dirty Indices (#13660) 2024-02-24 10:08:17 +00:00
contracts/deposit Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
crypto Switch gomock library (#13639) 2024-02-21 18:37:17 +00:00
encoding Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
hack Switch gomock library (#13639) 2024-02-21 18:37:17 +00:00
io Implement EIP-3076 minimal slashing protection, using a filesystem database (#13360) 2024-03-05 15:27:15 +00:00
math Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
monitoring Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
network Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
proto Remove deprecated items (#13600) 2024-02-15 15:23:31 +00:00
runtime Implement EIP-3076 minimal slashing protection, using a filesystem database (#13360) 2024-03-05 15:27:15 +00:00
testing small cleanup on functions (#13666) 2024-02-26 22:23:23 +00:00
third_party Downgrade Level DB to Stable Version (#13671) 2024-02-29 04:49:02 +00:00
time Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
tools Implement EIP-3076 minimal slashing protection, using a filesystem database (#13360) 2024-03-05 15:27:15 +00:00
validator Implement EIP-3076 minimal slashing protection, using a filesystem database (#13360) 2024-03-05 15:27:15 +00:00
.bazelrc pgo: Enable pgo behind release flag (#13158) 2023-11-08 13:33:26 +00:00
.bazelversion Bazel 7.0.0 (#13321) 2024-01-10 15:34:11 +00:00
.buildkite-bazelrc Bazel 7.0.0 (#13321) 2024-01-10 15:34:11 +00:00
.codecov.yml Codecov: ignore testing directories (#8777) 2021-04-16 08:44:36 -05:00
.deepsource.toml Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
.dockerignore Add tool and script for interop testing (#3417) 2019-09-09 17:31:19 -04:00
.gitattributes linguist-generated=true for mock and pb go files (#1465) 2019-02-02 17:25:28 -05:00
.gitignore E2E: beacon APIs Part 1 (#11306) 2022-12-06 16:01:17 +00:00
.golangci.yml Enable wastedassign linter & fix findings (#13507) 2024-01-25 17:07:48 +00:00
.policy.yml Include Policy Bot Application (#7523) 2020-10-14 04:14:38 +00:00
.travis.yml Resolve Proto Lint Issues (#3044) 2019-07-22 14:10:17 -05:00
bazel.sh Fix All Deep Source Shell Issues and Go Issues (#8661) 2021-03-24 19:57:27 +00:00
BUILD.bazel Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
CONTRIBUTING.md fix typo (CONTRIBUTING.md) (#12548) 2023-06-18 19:24:19 -07:00
DEPENDENCIES.md Update Gohashtree to v0.0.4-beta (#13569) 2024-02-01 15:42:56 +00:00
deps.bzl Downgrade Level DB to Stable Version (#13671) 2024-02-29 04:49:02 +00:00
distroless_deps.bzl docker: Add coreutils to docker images (#13564) 2024-02-03 19:21:21 +00:00
fuzzbuzz.yaml Update go to 1.19.3 (#11630) 2022-11-18 19:12:19 +00:00
go.mod Downgrade Level DB to Stable Version (#13671) 2024-02-29 04:49:02 +00:00
go.sum Downgrade Level DB to Stable Version (#13671) 2024-02-29 04:49:02 +00:00
INTEROP.md Remove deprecated items (#13600) 2024-02-15 15:23:31 +00:00
LICENSE.md update to GPLv3 (#297) 2018-07-20 10:23:48 -05:00
MODULE.bazel Bazel 7.0.0 (#13321) 2024-01-10 15:34:11 +00:00
MODULE.bazel.lock Bazel 7.0.0 (#13321) 2024-01-10 15:34:11 +00:00
nogo_config.json sort static analyzers, add more, fix violations (#13441) 2024-01-09 23:29:36 +00:00
prysm.bat Fix typos (#13053) 2023-10-19 12:23:11 +00:00
prysm.ps1 Update prysm scripts to support client-stats, deprecate slasher (#8971) 2021-06-02 14:06:59 -05:00
prysm.sh correctly assign arm64 arch for Apple M1 (#11675) 2022-11-21 23:11:02 +00:00
README.md Update README.md (#13302) 2023-12-08 04:07:10 +00:00
SECURITY.md Add how users should report security vulnerabilities for this repository (#9525) 2021-09-10 03:13:09 +00:00
service-account.json.enc Bazel cache for travis (#236) 2018-07-07 16:01:58 -04:00
TERMS_OF_SERVICE.md Update Terms of Service (#13163) 2023-11-02 17:11:11 +00:00
WORKSPACE Update bazel-lib to include https://github.com/aspect-build/bazel-lib/pull/768 (#13675) 2024-02-27 21:24:44 +00:00

Prysm: An Ethereum Consensus Implementation Written in Go

Build status Go Report Card Consensus_Spec_Version 1.3.0 Execution_API_Version 1.0.0-beta.2 Discord GitPOAP Badge

This is the core repository for Prysm, a Golang implementation of the Ethereum Consensus specification, developed by Offchain Labs. See the Changelog for details of the latest releases and upcoming breaking changes.

Getting Started

A detailed set of installation and usage instructions as well as breakdowns of each individual component are available in the official documentation portal. If you still have questions, feel free to stop by our Discord.

Staking on Mainnet

To participate in staking, you can join the official eth2 launchpad. The launchpad is the only recommended way to become a validator on mainnet. You can explore validator rewards/penalties via Bitfly's block explorer: beaconcha.in, and follow the latest blocks added to the chain on beaconscan.

Contributing

Branches

Prysm maintains two permanent branches:

  • master: This points to the latest stable release. It is ideal for most users.
  • develop: This is used for development, it contains the latest PRs. Developers should base their PRs on this branch.

Guide

Want to get involved? Check out our Contribution Guide to learn more!

License

GNU General Public License v3.0

Terms of Use