2021-08-13 16:53:04 +00:00
|
|
|
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
|
|
|
|
|
|
|
go_library(
|
|
|
|
name = "go_default_library",
|
|
|
|
srcs = [
|
2021-09-28 02:04:32 +00:00
|
|
|
"chunks.go",
|
2021-09-28 20:54:17 +00:00
|
|
|
"detect_attestations.go",
|
2021-09-28 19:33:45 +00:00
|
|
|
"detect_blocks.go",
|
2021-09-24 18:38:13 +00:00
|
|
|
"doc.go",
|
|
|
|
"helpers.go",
|
2021-09-29 02:27:21 +00:00
|
|
|
"log.go",
|
2021-09-28 02:04:32 +00:00
|
|
|
"metrics.go",
|
2021-08-13 16:53:04 +00:00
|
|
|
"params.go",
|
2021-09-28 15:27:40 +00:00
|
|
|
"process_slashings.go",
|
2021-09-28 18:13:16 +00:00
|
|
|
"queue.go",
|
|
|
|
"receive.go",
|
2021-08-13 16:53:04 +00:00
|
|
|
"service.go",
|
|
|
|
],
|
2024-02-15 05:46:47 +00:00
|
|
|
importpath = "github.com/prysmaticlabs/prysm/v5/beacon-chain/slasher",
|
2021-09-29 02:27:21 +00:00
|
|
|
visibility = [
|
|
|
|
"//beacon-chain:__subpackages__",
|
|
|
|
"//testing/slasher/simulator:__subpackages__",
|
|
|
|
],
|
2021-08-13 16:53:04 +00:00
|
|
|
deps = [
|
2021-09-28 18:13:16 +00:00
|
|
|
"//async/event:go_default_library",
|
2021-09-28 15:27:40 +00:00
|
|
|
"//beacon-chain/blockchain:go_default_library",
|
|
|
|
"//beacon-chain/core/blocks:go_default_library",
|
2021-09-28 18:13:16 +00:00
|
|
|
"//beacon-chain/core/feed/state:go_default_library",
|
2021-09-28 02:04:32 +00:00
|
|
|
"//beacon-chain/db:go_default_library",
|
2021-09-28 15:27:40 +00:00
|
|
|
"//beacon-chain/operations/slashings:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"//beacon-chain/slasher/types:go_default_library",
|
2023-05-03 04:34:01 +00:00
|
|
|
"//beacon-chain/startup:go_default_library",
|
2021-09-28 15:27:40 +00:00
|
|
|
"//beacon-chain/state/stategen:go_default_library",
|
2021-09-29 02:27:21 +00:00
|
|
|
"//beacon-chain/sync:go_default_library",
|
2021-12-15 20:14:30 +00:00
|
|
|
"//config/fieldparams:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"//config/params:go_default_library",
|
2022-04-29 14:32:11 +00:00
|
|
|
"//consensus-types/primitives:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"//container/slice:go_default_library",
|
2021-09-28 15:27:40 +00:00
|
|
|
"//encoding/bytesutil:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"//proto/prysm/v1alpha1:go_default_library",
|
2021-09-28 20:54:17 +00:00
|
|
|
"//time/slots:go_default_library",
|
2021-09-28 02:04:32 +00:00
|
|
|
"@com_github_pkg_errors//:go_default_library",
|
|
|
|
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
|
|
|
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
|
2022-06-28 13:03:24 +00:00
|
|
|
"@com_github_prysmaticlabs_fastssz//:go_default_library",
|
2021-08-13 16:53:04 +00:00
|
|
|
"@com_github_sirupsen_logrus//:go_default_library",
|
2021-09-28 19:33:45 +00:00
|
|
|
"@io_opencensus_go//trace:go_default_library",
|
2021-08-13 16:53:04 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
go_test(
|
|
|
|
name = "go_default_test",
|
2021-09-24 18:38:13 +00:00
|
|
|
srcs = [
|
2021-09-28 02:04:32 +00:00
|
|
|
"chunks_test.go",
|
2021-09-28 20:54:17 +00:00
|
|
|
"detect_attestations_test.go",
|
2021-09-28 19:33:45 +00:00
|
|
|
"detect_blocks_test.go",
|
2021-09-24 18:38:13 +00:00
|
|
|
"helpers_test.go",
|
|
|
|
"params_test.go",
|
2021-09-28 15:27:40 +00:00
|
|
|
"process_slashings_test.go",
|
2021-09-28 18:13:16 +00:00
|
|
|
"queue_test.go",
|
|
|
|
"receive_test.go",
|
2021-09-29 18:17:37 +00:00
|
|
|
"service_test.go",
|
2021-09-24 18:38:13 +00:00
|
|
|
],
|
2021-08-13 16:53:04 +00:00
|
|
|
embed = [":go_default_library"],
|
|
|
|
deps = [
|
2021-09-28 18:13:16 +00:00
|
|
|
"//async/event:go_default_library",
|
2021-09-28 15:27:40 +00:00
|
|
|
"//beacon-chain/blockchain/testing:go_default_library",
|
|
|
|
"//beacon-chain/core/signing:go_default_library",
|
2021-09-28 02:04:32 +00:00
|
|
|
"//beacon-chain/db/testing:go_default_library",
|
2022-09-28 20:10:27 +00:00
|
|
|
"//beacon-chain/forkchoice/doubly-linked-tree:go_default_library",
|
2022-01-26 14:48:20 +00:00
|
|
|
"//beacon-chain/operations/slashings/mock:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"//beacon-chain/slasher/types:go_default_library",
|
2023-05-03 04:34:01 +00:00
|
|
|
"//beacon-chain/startup:go_default_library",
|
2021-09-28 15:27:40 +00:00
|
|
|
"//beacon-chain/state/stategen:go_default_library",
|
2021-09-29 18:17:37 +00:00
|
|
|
"//beacon-chain/sync/initial-sync/testing:go_default_library",
|
2021-12-15 20:14:30 +00:00
|
|
|
"//config/fieldparams:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"//config/params:go_default_library",
|
2022-04-29 14:32:11 +00:00
|
|
|
"//consensus-types/primitives:go_default_library",
|
2021-09-28 15:27:40 +00:00
|
|
|
"//crypto/bls:go_default_library",
|
Slasher: Refactor and add tests (#13589)
* `helpers.go`: Improve naming consistency.
* `detect_attestations.go`: Improve readability.
* `receive.go`: Add `attsQueueSize` in log message.
* `checkSlashableAttestations`: Improve logging.
`avgBatchProcessingTime` is not displayed any more if not batch is
processed.
* `loadChunks`: Use explicit `chunkKind` and `chunkIndices`.
* `getChunk`: Use specific `chunkIndex` and `chunkKind`.
* `validatorIndicesInChunk` -> `validatorIndexesInChunk`.
* `epochUpdateForValidator`: Use explicit arguments.
* `getChunk`: Change order of arguments.
* `latestEpochWrittenForValidator`: Use `ok` parameter.
So the default value is not any more considered as the absence of
value.
* `applyAttestationForValidator`: Use explicit arguments.
* `updateSpans`: Use explicit arguments.
* `saveUpdatedChunks`: Use explicit arguments.
* `checkSurrounds`: Use explicit arguments.
We see here that, previously, in `checkSlashableAttestations`,
`checkSurrounds` was called with the default value of `slashertypes`: `MinSpan`.
Now, we set it expliciterly at `MinSpan`, which may explicit a bug.
* `epochUpdateForValidator`: Set modified by the function argument first.
* `applyAttestationForValidator`: Set mutated argument `chunksByChunkIdx`first.
* `applyAttestationForValidator`: Rename variables.
* `Test_processQueuedAttestations`: Fix test.
Two tests were actually exactly the same.
* `updateSpans`: Keep happy path in the outer scope.
Even if in this case the "happy" path means slashing.
* `checkSurrounds`: Rename variable.
* `getChunk`: Avoid side effects.
It adds a few lines for callers, but it does not modify any more
arguments and it does what it says: getting a chunk.
* `CheckSlashable`: Flatten.
* `detect_attestations_test.go`: Simplify.
* `CheckSlashable`: Add error log in case of missing attestation.
* `processQueuedAttestations`: Extract a sub function.
So testing will be easier.
* `processAttesterSlashings` and `processProposerSlashings`: Improve.
* `processAttesterSlashings`: Return processed slashings.
* `createAttestationWrapper`: Rename variables.
* `signingRoot` ==> `headerRoot` or `dataRoot`.
Before this commit, there is two typse of `signing root`s floating around.
- The first one is a real signing root, aka a hash tree root computed from an object root and
a domain. This real signing root is the object ready to be signed.
- The second one is a "false" signing root, which is actually just the hash tree root of an object. This object is either the `Data` field of an attestation, or the `Header` field of a block.
Having 2 differents objects with the same name `signing root` is quite confusing.
This commit renames wrongly named `signing root` objects.
* `createAttestationWrapper` => `createAttestationWrapperEmptySig`.
So it's clear for the user that the created attestation wrapper has an empty signature.
* Implement `createAttestationWrapper`.
* `processAttestations`: Return processed attester slashings.
* Test `processAttestations` instead of `processQueuedAttestations`.
By testing `processAttestations` instead of `processQueuedAttestations`, we get rid of a lot of tests fixtures, including the 200 ms sleep.
The whole testing duration is shorter.
* `Test_processAttestations`: Allow multiple steps.
* `Test_processAttestations`: Add double steps tests.
Some new failing tests are commented with a corresponding github issue.
* `NextChunkStartEpoch`: Fix function comment.
Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
* `chunks.go`: Avoid templating log messages.
* `checkSlashableAttestations`: Simplify duration computation.
---------
Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
2024-02-09 21:02:18 +00:00
|
|
|
"//crypto/bls/common:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"//encoding/bytesutil:go_default_library",
|
|
|
|
"//proto/prysm/v1alpha1:go_default_library",
|
2021-09-23 18:53:46 +00:00
|
|
|
"//testing/assert:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"//testing/require:go_default_library",
|
2021-09-28 15:27:40 +00:00
|
|
|
"//testing/util:go_default_library",
|
2021-09-29 18:17:37 +00:00
|
|
|
"//time/slots:go_default_library",
|
2022-06-28 13:03:24 +00:00
|
|
|
"@com_github_prysmaticlabs_fastssz//:go_default_library",
|
2021-09-29 18:17:37 +00:00
|
|
|
"@com_github_sirupsen_logrus//:go_default_library",
|
2021-09-24 18:38:13 +00:00
|
|
|
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
2021-08-13 16:53:04 +00:00
|
|
|
],
|
|
|
|
)
|