From 7597a065a1847f413de80bd4759438d939379b12 Mon Sep 17 00:00:00 2001 From: Christian <649785+chmllr@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:53:08 +0100 Subject: [PATCH] fix(halo/evmstaking2): improve delivered events metric (#2655) - changes the delivered events metric to only go up if at least one event was delivered - adds a new interval for staging for easier testing issue: #2525 --- halo/app/app_config.go | 10 ++++++++-- halo/evmstaking2/keeper/keeper.go | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/halo/app/app_config.go b/halo/app/app_config.go index b89fbc1f5..e72df9e5f 100644 --- a/halo/app/app_config.go +++ b/halo/app/app_config.go @@ -57,8 +57,10 @@ const ( genesisTrimLag uint64 = 1 // Allow deleting attestations in block after approval. genesisCTrimLag uint64 = 72_000 // Delete consensus attestations state after +-1 day (given a period of 1.2s). - deliverIntervalProtected = 20_000 // Roughly ~12h assumping 0.5bps - deliverIntervalEphemeral = 2 // Fast updates while testing + deliverIntervalProtected = 20_000 // Roughly ~12h assuming 0.5bps + // TODO(christian): remove after testing. + deliverIntervalStaging = 300 // Roughly ~10m assuming 0.5bps + deliverIntervalEphemeral = 2 // Fast updates while testing ) //nolint:gochecknoglobals // Cosmos-style @@ -245,6 +247,10 @@ var ( ) func deliverInterval(network netconf.ID) int64 { + if network == netconf.Staging { + return deliverIntervalStaging + } + if network.IsProtected() { return deliverIntervalProtected } diff --git a/halo/evmstaking2/keeper/keeper.go b/halo/evmstaking2/keeper/keeper.go index 61118a3cb..22ce4eedc 100644 --- a/halo/evmstaking2/keeper/keeper.go +++ b/halo/evmstaking2/keeper/keeper.go @@ -98,6 +98,7 @@ func (k *Keeper) EndBlock(ctx context.Context) error { } defer iter.Close() + delivered := false for iter.Next() { val, err := iter.Value() if err != nil { @@ -108,8 +109,12 @@ func (k *Keeper) EndBlock(ctx context.Context) error { if err != nil { return errors.Wrap(err, "delete evm event") } + delivered = true } - eventDeliveries.Inc() + if delivered { + eventDeliveries.Inc() + } + bufferedEvents.Set(0) return nil