From d2251f0fdfc7645268f1719566cd5949bed96594 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Wed, 24 Aug 2022 15:48:26 +1000 Subject: [PATCH 1/2] fix(execution): Fix panic when nil block is returned --- pkg/exporter/execution/jobs/block.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/exporter/execution/jobs/block.go b/pkg/exporter/execution/jobs/block.go index 2978347..7b500b6 100644 --- a/pkg/exporter/execution/jobs/block.go +++ b/pkg/exporter/execution/jobs/block.go @@ -223,6 +223,10 @@ func (b *BlockMetrics) getHeadBlockStats(ctx context.Context) error { return err } + if block == nil { + return errors.New("block is nil") + } + b.HeadGasUsed.Set(float64(block.GasUsed)) b.HeadGasLimit.Set(float64(block.GasLimit)) b.HeadBlockSize.Set(float64(block.Size)) From 174b6230923fc01bdc8358c69cddb9e5f5c00d1a Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Wed, 24 Aug 2022 15:51:52 +1000 Subject: [PATCH 2/2] chore: linting --- pkg/exporter/consensus/jobs/beacon.go | 2 +- pkg/exporter/consensus/jobs/spec.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/exporter/consensus/jobs/beacon.go b/pkg/exporter/consensus/jobs/beacon.go index 667c722..fa38b77 100644 --- a/pkg/exporter/consensus/jobs/beacon.go +++ b/pkg/exporter/consensus/jobs/beacon.go @@ -260,7 +260,7 @@ func (b *Beacon) handleBlockInserted(ctx context.Context, event *beacon.BlockIns return err } - // nolint:gocritic // False positive + //nolint:gocritic // False positive if err = b.handleSingleBlock("head", timedBlock.Block); err != nil { return err } diff --git a/pkg/exporter/consensus/jobs/spec.go b/pkg/exporter/consensus/jobs/spec.go index 7f5bdb9..7bca403 100644 --- a/pkg/exporter/consensus/jobs/spec.go +++ b/pkg/exporter/consensus/jobs/spec.go @@ -290,16 +290,16 @@ func (s *Spec) observeSpec(ctx context.Context, spec *state.Spec) error { s.SafeSlotsToUpdateJustified.Set(float64(spec.SafeSlotsToUpdateJustified)) s.DepositChainID.Set(float64(spec.DepositChainID)) s.MaxValidatorsPerCommittee.Set(float64(spec.MaxValidatorsPerCommittee)) - // nolint:unconvert // false positive + //nolint:unconvert // false positive s.SecondsPerEth1Block.Set(float64(spec.SecondsPerEth1Block.Seconds())) s.BaseRewardFactor.Set(float64(spec.BaseRewardFactor)) s.EpochsPerSyncCommitteePeriod.Set(float64(spec.EpochsPerSyncCommitteePeriod)) s.EffectiveBalanceIncrement.Set(float64(spec.EffectiveBalanceIncrement)) s.MaxAttestations.Set(float64(spec.MaxAttestations)) s.MinSyncCommitteeParticipants.Set(float64(spec.MinSyncCommitteeParticipants)) - // nolint:unconvert // false positive + //nolint:unconvert // false positive s.GenesisDelay.Set(float64(spec.GenesisDelay.Seconds())) - // nolint:unconvert // false positive + //nolint:unconvert // false positive s.SecondsPerSlot.Set(float64(spec.SecondsPerSlot.Seconds())) s.MaxEffectiveBalance.Set(float64(spec.MaxEffectiveBalance)) s.MaxDeposits.Set(float64(spec.MaxDeposits))