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

Detect attestation with source or target lower then min as slahsable #7902

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
bfb1ddf
refactor slashing protection
rauljordan Nov 17, 2020
f69f651
refactor items
rauljordan Nov 18, 2020
a9169cf
revamp the is slashable block method
rauljordan Nov 18, 2020
a5fcae2
simplification of proposer protect
rauljordan Nov 18, 2020
0205f4c
remote functions modified
rauljordan Nov 18, 2020
c4e4d29
further work on simplifying protection
rauljordan Nov 18, 2020
ad73cbf
fix red lines
rauljordan Nov 18, 2020
987cbcd
revert
rauljordan Nov 18, 2020
afdeaf6
attempt to fix more tests
rauljordan Nov 18, 2020
3d9b41f
test many slashable attempts in parallel
rauljordan Nov 18, 2020
35356c3
many surround voting attestations in parallel test
rauljordan Nov 18, 2020
39716e1
get full package to build
rauljordan Nov 18, 2020
f1eb9b3
tests pass without parallelism
rauljordan Nov 18, 2020
3400b67
fix up protection tests
rauljordan Nov 18, 2020
9d4aee0
iface refactor
rauljordan Nov 18, 2020
82f58ce
Merge branch 'master' into protection-refactor
rauljordan Nov 18, 2020
888e0fb
align to interface
rauljordan Nov 18, 2020
3604f7f
tests passing
rauljordan Nov 18, 2020
50837e0
include new protection
rauljordan Nov 18, 2020
fe9c382
allow validator bazel build
rauljordan Nov 18, 2020
85d489d
move update history function into the right place
rauljordan Nov 18, 2020
cc2573e
attesting history manager iface
rauljordan Nov 18, 2020
dc79e29
history manager iface implementation
rauljordan Nov 18, 2020
23095d0
separate remote files
rauljordan Nov 18, 2020
f4cdb2e
propose block tests pass
rauljordan Nov 18, 2020
29bdbfb
fix up service tests
rauljordan Nov 18, 2020
b952e05
all tests pass
rauljordan Nov 18, 2020
2b3f7de
Merge branch 'master' into protection-refactor
rauljordan Nov 18, 2020
bdce13c
viz
rauljordan Nov 18, 2020
ce43fb7
Merge branch 'protection-refactor' of github.com:prysmaticlabs/prysm …
rauljordan Nov 18, 2020
ae4cded
deep source
rauljordan Nov 18, 2020
7f46bbf
deps
rauljordan Nov 18, 2020
320e085
go proto
rauljordan Nov 18, 2020
ebd0ad3
preston feedback
rauljordan Nov 18, 2020
21a1290
split up some helper methods
rauljordan Nov 18, 2020
4c1e5ef
more Preston's feedback
rauljordan Nov 19, 2020
37c4840
pass in signing root
rauljordan Nov 19, 2020
d1169a0
tests passing when using signing root
rauljordan Nov 19, 2020
024790d
amend proposal hist function but needs tests
rauljordan Nov 19, 2020
371fbdf
check against slasher specific errors
rauljordan Nov 19, 2020
9572783
wrapped up
rauljordan Nov 19, 2020
0f94ada
tests for is double vote helper func
rauljordan Nov 19, 2020
828ebfd
fix all tests
rauljordan Nov 19, 2020
10692fa
Merge branch 'master' into protection-refactor
rauljordan Nov 19, 2020
2f4a862
gaz
rauljordan Nov 19, 2020
e47f6d5
Merge branch 'protection-refactor' of github.com:prysmaticlabs/prysm …
rauljordan Nov 19, 2020
488b8f8
terence feedback
rauljordan Nov 19, 2020
b6dba87
debug logging in validator
prestonvanloon Nov 19, 2020
148848a
refactor with Terences suggestions
rauljordan Nov 19, 2020
be9cc78
Merge branch 'protection-refactor' of github.com:prysmaticlabs/prysm …
rauljordan Nov 19, 2020
f7d24ff
comments
rauljordan Nov 19, 2020
96bec2d
add ctx err
rauljordan Nov 19, 2020
1b1cb08
more logging
rauljordan Nov 19, 2020
068ff0d
initialize hist manager
rauljordan Nov 19, 2020
dab6239
add proposer index
rauljordan Nov 19, 2020
78e8a26
further debug
rauljordan Nov 19, 2020
d1404b7
more logging
rauljordan Nov 19, 2020
0ca9a19
using sync map
rauljordan Nov 19, 2020
01d108b
use pointer
rauljordan Nov 19, 2020
bbf5c9e
sync map and multilock
rauljordan Nov 19, 2020
644ee50
multilock
rauljordan Nov 19, 2020
92ababb
multilock logs
rauljordan Nov 19, 2020
f6e16d4
logs around attest
rauljordan Nov 19, 2020
7d6e64c
rem import
rauljordan Nov 19, 2020
df75cfc
1 beacon node
rauljordan Nov 19, 2020
377820a
no remote
rauljordan Nov 19, 2020
5437c92
no min sync peers
rauljordan Nov 19, 2020
3aa2118
regular map
rauljordan Nov 19, 2020
be86238
revert e2e
rauljordan Nov 19, 2020
73ad72b
no more in-memory att histories
rauljordan Nov 20, 2020
26454a3
add log for surround voting
rauljordan Nov 20, 2020
68f720a
gaz
rauljordan Nov 20, 2020
7d1cbd7
viz
rauljordan Nov 20, 2020
8ce8def
nil check
rauljordan Nov 20, 2020
d60ae02
protect attester details
rauljordan Nov 20, 2020
f82b94a
rem log
rauljordan Nov 20, 2020
c1508c4
better surround vote implementation
rauljordan Nov 20, 2020
db185e9
preston feedback
rauljordan Nov 20, 2020
1f6c777
Merge branch 'master' into protection-refactor
rauljordan Nov 20, 2020
fefef29
better fmt
rauljordan Nov 20, 2020
02c6b76
gaz
rauljordan Nov 20, 2020
274f1fc
Merge branch 'protection-refactor' of github.com:prysmaticlabs/prysm …
rauljordan Nov 20, 2020
be9c44f
Minimal proposal signing slot
shayzluf Nov 20, 2020
6de50b3
start minimal slot support in db
shayzluf Nov 20, 2020
875acec
minimal slot signing tests
shayzluf Nov 20, 2020
e9008c5
fix tests
shayzluf Nov 20, 2020
588dd7f
fix test
shayzluf Nov 20, 2020
82c9665
flip order of target and source
rauljordan Nov 20, 2020
3d44244
Merge branch 'master' into protection-refactor
rauljordan Nov 20, 2020
3b2346e
Merge branch 'master' into protection-refactor
rauljordan Nov 20, 2020
2208da1
exit early if local protection catches a slashing
rauljordan Nov 20, 2020
b614253
Merge branch 'protection-refactor' of github.com:prysmaticlabs/prysm …
rauljordan Nov 20, 2020
6776514
miscellaneous nishant feedback resolutions
rauljordan Nov 20, 2020
bcc2ccc
add feature flags and remove old methods
rauljordan Nov 20, 2020
9ec2187
gaz
rauljordan Nov 20, 2020
ea4ccdc
remove deprecated code!
rauljordan Nov 20, 2020
fad64f4
iface refactors
rauljordan Nov 20, 2020
196028a
bazel
rauljordan Nov 20, 2020
cf66061
tests pass
rauljordan Nov 20, 2020
a09ad67
new history implementation
rauljordan Nov 20, 2020
46a739b
new history tests
rauljordan Nov 21, 2020
8b46416
refactor attesting history
rauljordan Nov 21, 2020
f960bee
tests pass
rauljordan Nov 21, 2020
efd7b67
viz rules
rauljordan Nov 21, 2020
f9b21ec
fix confs
rauljordan Nov 21, 2020
e9efc66
dbtest
rauljordan Nov 21, 2020
5fb9555
nil check
rauljordan Nov 21, 2020
732638a
Merge branch 'master' into protection-refactor
rauljordan Nov 21, 2020
806565a
Merge branch 'protection-refactor' of github.com:prysmaticlabs/prysm …
shayzluf Nov 22, 2020
fc7f183
remove empty file
shayzluf Nov 22, 2020
e514da2
remove fmt
shayzluf Nov 22, 2020
a78df5f
Add min source and min target to protection history structure
shayzluf Nov 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions endtoend/components/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func StartNewValidatorClient(t *testing.T, config *types.E2EConfig, validatorNum
"--force-clear-db",
"--e2e-config",
"--accept-terms-of-use",
"--verbosity=debug",
}
args = append(args, featureconfig.E2EValidatorFlags...)
args = append(args, config.ValidatorFlags...)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ require (
github.com/trailofbits/go-mutexasserts v0.0.0-20200708152505-19999e7d3cef
github.com/tyler-smith/go-bip39 v1.0.2
github.com/urfave/cli/v2 v2.2.0
github.com/wealdtech/go-bytesutil v1.1.1
github.com/wealdtech/go-eth2-util v1.6.2
github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.1
github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3
Expand Down
30 changes: 18 additions & 12 deletions shared/featureconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ type Flags struct {
PyrmontTestnet bool // PyrmontTestnet defines the flag through which we can enable the node to run on the Pyrmont testnet.

// Feature related flags.
WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory.
SkipBLSVerify bool // Skips BLS verification across the runtime.
EnableBlst bool // Enables new BLS library from supranational.
PruneEpochBoundaryStates bool // PruneEpochBoundaryStates prunes the epoch boundary state before last finalized check point.
EnableSnappyDBCompression bool // EnableSnappyDBCompression in the database.
SlasherProtection bool // SlasherProtection protects validator fron sending over a slashable offense over the network using external slasher.
EnableNoise bool // EnableNoise enables the beacon node to use NOISE instead of SECIO when performing a handshake with another peer.
EnableEth1DataMajorityVote bool // EnableEth1DataMajorityVote uses the Voting With The Majority algorithm to vote for eth1data.
EnablePeerScorer bool // EnablePeerScorer enables experimental peer scoring in p2p.
EnablePruningDepositProofs bool // EnablePruningDepositProofs enables pruning deposit proofs which significantly reduces the size of a deposit
EnableSyncBacktracking bool // EnableSyncBacktracking enables backtracking algorithm when searching for alternative forks during initial sync.
EnableLargerGossipHistory bool // EnableLargerGossipHistory increases the gossip history we store in our caches.
WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory.
SkipBLSVerify bool // Skips BLS verification across the runtime.
EnableBlst bool // Enables new BLS library from supranational.
PruneEpochBoundaryStates bool // PruneEpochBoundaryStates prunes the epoch boundary state before last finalized check point.
EnableSnappyDBCompression bool // EnableSnappyDBCompression in the database.
SlasherProtection bool // SlasherProtection protects validator fron sending over a slashable offense over the network using external slasher.
EnableNoise bool // EnableNoise enables the beacon node to use NOISE instead of SECIO when performing a handshake with another peer.
EnableEth1DataMajorityVote bool // EnableEth1DataMajorityVote uses the Voting With The Majority algorithm to vote for eth1data.
EnablePeerScorer bool // EnablePeerScorer enables experimental peer scoring in p2p.
EnablePruningDepositProofs bool // EnablePruningDepositProofs enables pruning deposit proofs which significantly reduces the size of a deposit
EnableSyncBacktracking bool // EnableSyncBacktracking enables backtracking algorithm when searching for alternative forks during initial sync.
EnableLargerGossipHistory bool // EnableLargerGossipHistory increases the gossip history we store in our caches.
DisableStrictRemoteSlashingProtection bool // DisableStrictRemoteSlashing protection allows submitting attestations and blocks if slasher is unavailable.

// Logging related toggles.
DisableGRPCConnectionLogs bool // Disables logging when a new grpc client has connected.
Expand Down Expand Up @@ -206,6 +207,11 @@ func ConfigureValidator(ctx *cli.Context) {
log.Warn("Enabled validator attestation and block slashing protection using an external slasher.")
cfg.SlasherProtection = true
}
if ctx.Bool(disableStrictRemoteSlashingProtection.Name) {
log.Warn("Disabling strict remote slashing protection. Blocks and attestations will still be " +
"submitted if slasher returns gRPC error code UNAVAILABLE, CONTEXT_CANCELED, or RESOURCE_EXHAUSTED")
cfg.DisableStrictRemoteSlashingProtection = true
}
Init(cfg)
}

Expand Down
7 changes: 7 additions & 0 deletions shared/featureconfig/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ var (
Name: "disable-grpc-connection-logging",
Usage: "Disables displaying logs for newly connected grpc clients",
}
disableStrictRemoteSlashingProtection = &cli.BoolFlag{
Name: "disable-strict-remote-slashing-protection",
Usage: "Allows submitting attestations and blocks to the beacon node from the validator client if " +
"remote slasher protection returns gRPC error code " +
"UNAVAILABLE, CANCELED, or RESOURCE_EXHAUSTED",
}
attestationAggregationStrategy = &cli.StringFlag{
Name: "attestation-aggregation-strategy",
Usage: "Which strategy to use when aggregating attestations, one of: naive, max_cover.",
Expand Down Expand Up @@ -100,6 +106,7 @@ var ValidatorFlags = append(deprecatedFlags, []cli.Flag{
Mainnet,
disableAccountsV2,
disableBlst,
disableStrictRemoteSlashingProtection,
}...)

// SlasherFlags contains a list of all the feature flags that apply to the slasher client.
Expand Down
10 changes: 2 additions & 8 deletions validator/client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ go_library(
srcs = [
"aggregate.go",
"attest.go",
"attest_protect.go",
"log.go",
"metrics.go",
"mock_validator.go",
"multiple_endpoints_grpc_resolver.go",
"propose.go",
"propose_protect.go",
"runner.go",
"service.go",
"validator.go",
Expand All @@ -22,7 +19,6 @@ go_library(
deps = [
"//beacon-chain/core/helpers:go_default_library",
"//proto/validator/accounts/v2:go_default_library",
"//shared/blockutil:go_default_library",
"//shared/bls:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
Expand All @@ -34,10 +30,10 @@ go_library(
"//shared/timeutils:go_default_library",
"//validator/accounts/wallet:go_default_library",
"//validator/db:go_default_library",
"//validator/db/kv:go_default_library",
"//validator/keymanager:go_default_library",
"//validator/keymanager/imported:go_default_library",
"//validator/slashing-protection:go_default_library",
"//validator/slashing-protection/remote:go_default_library",
"@com_github_dgraph_io_ristretto//:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
Expand Down Expand Up @@ -68,10 +64,9 @@ go_test(
size = "small",
srcs = [
"aggregate_test.go",
"attest_protect_test.go",
"attest_test.go",
"metrics_test.go",
"propose_protect_test.go",
"mock_validator_test.go",
"propose_test.go",
"runner_test.go",
"service_test.go",
Expand All @@ -93,7 +88,6 @@ go_test(
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"//shared/timeutils:go_default_library",
"//validator/db/kv:go_default_library",
"//validator/db/testing:go_default_library",
"//validator/testing:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
Expand Down
80 changes: 60 additions & 20 deletions validator/client/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
validatorpb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/slotutil"
"github.com/prysmaticlabs/prysm/shared/timeutils"
"github.com/prysmaticlabs/prysm/validator/slashing-protection/remote"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
)
Expand Down Expand Up @@ -63,13 +65,6 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot uint64, pubKey [
AttestingIndices: []uint64{duty.ValidatorIndex},
Data: data,
}
if err := v.preAttSignValidations(ctx, indexedAtt, pubKey); err != nil {
log.WithFields(logrus.Fields{
"sourceEpoch": indexedAtt.Data.Source.Epoch,
"targetEpoch": indexedAtt.Data.Target.Epoch,
}).WithError(err).Error("Failed attestation safety check")
return
}

sig, signingRoot, err := v.signAtt(ctx, pubKey, data)
if err != nil {
Expand All @@ -79,6 +74,45 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot uint64, pubKey [
}
return
}
indexedAtt.Signature = sig
locallySlashable, err := v.localSlashingProtector.IsSlashableAttestation(ctx, indexedAtt, pubKey, signingRoot)
if err != nil {
log.WithFields(
attestationLogFields(pubKey, indexedAtt),
).WithError(err).Error("Could not check attestation safety with local slashing protection, not submitting")
return
}
if locallySlashable {
log.WithFields(
attestationLogFields(pubKey, indexedAtt),
).Warn("Attempted to submit a slashable attestation, blocked by local slashing protection")
return
}
if remoteProtector, ok := v.remoteSlashingProtector.(*remote.Service); ok && remoteProtector != nil {
remoteSlashable, err := v.remoteSlashingProtector.IsSlashableAttestation(ctx, indexedAtt, pubKey, signingRoot)
if err != nil {
if featureconfig.Get().DisableStrictRemoteSlashingProtection {
if !errors.Is(err, remote.ErrSlasherUnavailable) {
// If slasher is unavailable, trust local protection and proceed with submitting the attestation.
log.WithFields(
attestationLogFields(pubKey, indexedAtt),
).WithError(err).Warn("Could not check attestation safety with remote slashing protection, not submitting")
return
}
} else {
log.WithFields(
attestationLogFields(pubKey, indexedAtt),
).WithError(err).Warn("Could not check attestation safety with remote slashing protection, not submitting")
return
}
}
if remoteSlashable {
log.WithFields(
attestationLogFields(pubKey, indexedAtt),
).Warn("Attempted to submit a slashable attestation, blocked by remote slashing protection")
return
}
}

var indexInCommittee uint64
var found bool
Expand All @@ -105,15 +139,6 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot uint64, pubKey [
Signature: sig,
}

indexedAtt.Signature = sig
if err := v.postAttSignUpdate(ctx, indexedAtt, pubKey, signingRoot); err != nil {
log.WithFields(logrus.Fields{
"sourceEpoch": indexedAtt.Data.Source.Epoch,
"targetEpoch": indexedAtt.Data.Target.Epoch,
}).WithError(err).Error("Failed post attestation signing updates")
return
}

attResp, err := v.validatorClient.ProposeAttestation(ctx, attestation)
if err != nil {
log.WithError(err).Error("Could not submit attestation to beacon node")
Expand All @@ -122,9 +147,6 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot uint64, pubKey [
}
return
}
if err := v.SaveProtection(ctx, pubKey); err != nil {
log.WithError(err).Errorf("Could not save validator: %#x protection", pubKey)
}

if err := v.saveAttesterIndexToData(data, duty.ValidatorIndex); err != nil {
log.WithError(err).Error("Could not save validator index for logging")
Expand Down Expand Up @@ -166,7 +188,11 @@ func (v *validator) duty(pubKey [48]byte) (*ethpb.DutiesResponse_Duty, error) {
}

// Given validator's public key, this function returns the signature of an attestation data and its signing root.
func (v *validator) signAtt(ctx context.Context, pubKey [48]byte, data *ethpb.AttestationData) ([]byte, [32]byte, error) {
func (v *validator) signAtt(
ctx context.Context,
pubKey [48]byte,
data *ethpb.AttestationData,
) ([]byte, [32]byte, error) {
domain, root, err := v.getDomainAndSigningRoot(ctx, data)
if err != nil {
return nil, [32]byte{}, err
Expand Down Expand Up @@ -227,3 +253,17 @@ func (v *validator) waitToSlotOneThird(ctx context.Context, slot uint64) {
finalTime := startTime.Add(delay)
time.Sleep(timeutils.Until(finalTime))
}

func attestationLogFields(pubKey [48]byte, indexedAtt *ethpb.IndexedAttestation) logrus.Fields {
return logrus.Fields{
"attesterPublicKey": fmt.Sprintf("%#x", pubKey),
"attestationSlot": indexedAtt.Data.Slot,
"committeeIndex": indexedAtt.Data.CommitteeIndex,
"beaconBlockRoot": fmt.Sprintf("%#x", indexedAtt.Data.BeaconBlockRoot),
"sourceEpoch": indexedAtt.Data.Source.Epoch,
"sourceRoot": fmt.Sprintf("%#x", indexedAtt.Data.Source.Root),
"targetEpoch": indexedAtt.Data.Target.Epoch,
"targetRoot": fmt.Sprintf("%#x", indexedAtt.Data.Target.Root),
"signature": fmt.Sprintf("%#x", indexedAtt.Signature),
}
}
Loading