From 70143ef7db22a3eb1884504d85498791aefb350f Mon Sep 17 00:00:00 2001 From: terencechain Date: Sat, 26 Aug 2023 09:33:11 -0700 Subject: [PATCH] chore: improve att error (#12813) --- beacon-chain/core/helpers/attestation.go | 8 +++++++- beacon-chain/core/helpers/attestation_test.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/beacon-chain/core/helpers/attestation.go b/beacon-chain/core/helpers/attestation.go index b3246c28b56e..af7d57f19de1 100644 --- a/beacon-chain/core/helpers/attestation.go +++ b/beacon-chain/core/helpers/attestation.go @@ -191,7 +191,13 @@ func ValidateAttestationTime(attSlot primitives.Slot, genesisTime time.Time, clo } attSlotEpoch := slots.ToEpoch(attSlot) if attSlotEpoch != currentEpoch && attSlotEpoch != prevEpoch { - return fmt.Errorf("attestation slot %d not within current epoch %d or previous epoch %d", attSlot, currentEpoch, prevEpoch) + attError = fmt.Errorf( + "attestation epoch %d not within current epoch %d or previous epoch %d", + attSlot/params.BeaconConfig().SlotsPerEpoch, + currentEpoch, + prevEpoch, + ) + return errors.Join(ErrTooLate, attError) } return nil diff --git a/beacon-chain/core/helpers/attestation_test.go b/beacon-chain/core/helpers/attestation_test.go index 3e1b117d9f36..932dc41b33d2 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -191,7 +191,7 @@ func Test_ValidateAttestationTime(t *testing.T) { -500 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second, ).Add(200 * time.Millisecond), }, - wantedErr: "attestation slot 268 not within current epoch 15 or previous epoch 14", + wantedErr: "attestation epoch 8 not within current epoch 15 or previous epoch 14", }, { name: "attestation.slot is well beyond current slot",