From 1c33427e79c7fd7e3e86983fa71df7f65ea20a0b Mon Sep 17 00:00:00 2001 From: Roy-blox Date: Sun, 8 Dec 2024 12:03:47 +0200 Subject: [PATCH] testing leader node cached att data --- beacon/goclient/attest.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/beacon/goclient/attest.go b/beacon/goclient/attest.go index ead167774e..c05d654872 100644 --- a/beacon/goclient/attest.go +++ b/beacon/goclient/attest.go @@ -10,6 +10,7 @@ import ( "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/jellydator/ttlcache/v3" + "go.uber.org/zap" ) // AttesterDuties returns attester duties for a given epoch. @@ -48,8 +49,8 @@ func (gc *GoClient) GetAttestationData(slot phase0.Slot, committeeIndex phase0.C } // Have to make beacon node request and cache the result. + attDataReqStart := time.Now() result, err, _ := gc.attestationReqInflight.Do(slot, func() (*phase0.AttestationData, error) { - attDataReqStart := time.Now() resp, err := gc.client.AttestationData(gc.ctx, &api.AttestationDataOpts{ Slot: slot, }) @@ -64,9 +65,12 @@ func (gc *GoClient) GetAttestationData(slot phase0.Slot, committeeIndex phase0.C // Caching resulting value here (as part of inflight request) guarantees only 1 request // will ever be done for a given slot. gc.attestationDataCache.Set(slot, resp.Data, ttlcache.DefaultTTL) - return resp.Data, nil }) + + gc.log.Debug("successfully fetched attestation data", + zap.Uint64("slot", uint64(slot)), + zap.Duration("attestation_data_time", time.Since(attDataReqStart))) if err != nil { return nil, DataVersionNil, err }