Skip to content

Commit

Permalink
Check seeds (#4901)
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Feb 18, 2020
1 parent 0e37b49 commit c0d4cab
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions beacon-chain/blockchain/process_attestation_helpers.go
Expand Up @@ -2,6 +2,7 @@ package blockchain

import (
"context"
"encoding/hex"
"fmt"

"github.com/pkg/errors"
Expand Down Expand Up @@ -95,6 +96,28 @@ func (s *Service) verifyAttestation(ctx context.Context, baseState *stateTrie.Be
}

if err := blocks.VerifyIndexedAttestation(ctx, baseState, indexedAtt); err != nil {
if err == blocks.ErrSigFailedToVerify {
// When sig fails to verify, check if there's a differences in committees due to
// different seeds.
aState, err := s.beaconDB.State(ctx, bytesutil.ToBytes32(a.Data.BeaconBlockRoot))
if err != nil {
return nil, err
}
epoch := helpers.SlotToEpoch(a.Data.Slot)
origSeed, err := helpers.Seed(baseState, epoch, params.BeaconConfig().DomainBeaconAttester)
if err != nil {
return nil, errors.Wrap(err, "could not get original seed")
}

aSeed, err := helpers.Seed(aState, epoch, params.BeaconConfig().DomainBeaconAttester)
if err != nil {
return nil, errors.Wrap(err, "could not get attester's seed")
}
if origSeed != aSeed {
return nil, fmt.Errorf("could not verify indexed attestation due to differences in seeds: %v != %v",
hex.EncodeToString(bytesutil.Trunc(origSeed[:])), hex.EncodeToString(bytesutil.Trunc(aSeed[:])))
}
}
return nil, errors.Wrap(err, "could not verify indexed attestation")
}

Expand Down

0 comments on commit c0d4cab

Please sign in to comment.