From 191bbf77accfc2523fa9f909837a2e9dca132afa Mon Sep 17 00:00:00 2001 From: rkapka Date: Wed, 26 Jun 2024 19:14:34 +0200 Subject: [PATCH] fix e2e --- beacon-chain/slasher/detect_attestations.go | 20 ++++++++++++++++++-- testing/endtoend/evaluators/slashing.go | 4 ++-- testing/slasher/simulator/simulator.go | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/beacon-chain/slasher/detect_attestations.go b/beacon-chain/slasher/detect_attestations.go index 0817e12ce6ae..c06e4873aec1 100644 --- a/beacon-chain/slasher/detect_attestations.go +++ b/beacon-chain/slasher/detect_attestations.go @@ -193,7 +193,15 @@ func (s *Service) checkDoubleVotes( // This is a double vote. doubleVotesTotal.Inc() - existing, ok := existingAttWrapper.IndexedAttestation.(*ethpb.IndexedAttestation) + existingWrapper, ok := existingAttWrapper.IndexedAttestation.(*slashertypes.WrappedIndexedAtt) + if !ok { + return nil, fmt.Errorf( + "existing attestation has wrong type (expected %T, got %T)", + &slashertypes.WrappedIndexedAtt{}, + existingAttWrapper.IndexedAttestation, + ) + } + existing, ok := existingWrapper.IndexedAtt.(*ethpb.IndexedAttestation) if !ok { return nil, fmt.Errorf( "existing attestation has wrong type (expected %T, got %T)", @@ -201,7 +209,15 @@ func (s *Service) checkDoubleVotes( existingAttWrapper.IndexedAttestation, ) } - incoming, ok := incomingAttWrapper.IndexedAttestation.(*ethpb.IndexedAttestation) + incomingWrapper, ok := incomingAttWrapper.IndexedAttestation.(*slashertypes.WrappedIndexedAtt) + if !ok { + return nil, fmt.Errorf( + "incoming attestation has wrong type (expected %T, got %T)", + &slashertypes.WrappedIndexedAtt{}, + incomingAttWrapper.IndexedAttestation, + ) + } + incoming, ok := incomingWrapper.IndexedAtt.(*ethpb.IndexedAttestation) if !ok { return nil, fmt.Errorf( "incoming attestation has wrong type (expected %T, got %T)", diff --git a/testing/endtoend/evaluators/slashing.go b/testing/endtoend/evaluators/slashing.go index 9ce26403b39c..550e69233284 100644 --- a/testing/endtoend/evaluators/slashing.go +++ b/testing/endtoend/evaluators/slashing.go @@ -52,7 +52,7 @@ var ValidatorsSlashedAfterEpoch = func(n primitives.Epoch) e2eTypes.Evaluator { // SlashedValidatorsLoseBalanceAfterEpoch checks if the validators slashed lose the right balance. var SlashedValidatorsLoseBalanceAfterEpoch = func(n primitives.Epoch) e2eTypes.Evaluator { return e2eTypes.Evaluator{ - Name: "slashed_validators_lose_valance_epoch_%d", + Name: "slashed_validators_lose_balance_epoch_%d", Policy: policies.AfterNthEpoch(n), Evaluation: validatorsLoseBalance, } @@ -109,7 +109,7 @@ func validatorsLoseBalance(_ *e2eTypes.EvaluationContext, conns ...*grpc.ClientC slashedBal := params.BeaconConfig().MaxEffectiveBalance - slashedPenalty + params.BeaconConfig().EffectiveBalanceIncrement/10 if valResp.EffectiveBalance >= slashedBal { return fmt.Errorf( - "expected slashed validator %d to balance less than %d, received %d", + "expected slashed validator %d balance to be less than %d, received %d", i, slashedBal, valResp.EffectiveBalance, diff --git a/testing/slasher/simulator/simulator.go b/testing/slasher/simulator/simulator.go index 67940a7504db..e09f13d95bc0 100644 --- a/testing/slasher/simulator/simulator.go +++ b/testing/slasher/simulator/simulator.go @@ -212,7 +212,7 @@ func (s *Simulator) simulateBlocksAndAttestations(ctx context.Context) { } log.WithFields(logrus.Fields{ "numAtts": len(atts), - "numSlashable": len(propSlashings), + "numSlashable": len(attSlashings), }).Infof("Producing attestations for slot %d", slot) for _, sl := range attSlashings { slashingRoot, err := sl.HashTreeRoot()