@@ -2,7 +2,7 @@ const std = @import("std");
22const Allocator = std .mem .Allocator ;
33const m = @import ("metrics" );
44
5- const CachedBeaconStateAllForks = @import ("cache/state_cache.zig" ).CachedBeaconStateAllForks ;
5+ const CachedBeaconState = @import ("cache/state_cache.zig" ).CachedBeaconState ;
66
77/// Defaults to noop metrics, making this safe to use whether or not `metrics.init` is called.
88pub var state_transition = m .initializeNoop (Metrics );
@@ -84,25 +84,29 @@ const Metrics = struct {
8484 const PreStateClonedCount = m .Histogram (u32 , &.{ 1 , 2 , 5 , 10 , 50 , 250 });
8585 const ProposerRewardsGauge = m .GaugeVec (u64 , ProposerRewardLabel );
8686
87- pub fn onStateClone (self : * Metrics , state : * CachedBeaconStateAllForks , source : StateCloneSource ) ! void {
88- try if (state .state .balances ().items .len > 0 )
87+ pub fn onStateClone (self : * Metrics , state : * CachedBeaconState , source : StateCloneSource ) ! void {
88+ var balances = try state .state .balances ();
89+ try if (try balances .length () > 0 )
8990 self .pre_state_balances_nodes_populated_hit .incr (.{ .source = source })
9091 else
9192 self .pre_state_balances_nodes_populated_miss .incr (.{ .source = source });
9293
93- try if (state .state .validators ().items .len > 0 )
94+ var validators = try state .state .validators ();
95+ try if (try validators .length () > 0 )
9496 self .pre_state_validators_nodes_populated_hit .incr (.{ .source = source })
9597 else
9698 self .pre_state_validators_nodes_populated_miss .incr (.{ .source = source });
9799 }
98100
99- pub fn onPostState (self : * Metrics , state : * CachedBeaconStateAllForks ) void {
100- if (state .state .balances ().items .len > 0 )
101+ pub fn onPostState (self : * Metrics , state : * CachedBeaconState ) ! void {
102+ var balances = try state .state .balances ();
103+ if (try balances .length () > 0 )
101104 self .post_state_balances_nodes_populated_hit .incr ()
102105 else
103106 self .post_state_balances_nodes_populated_miss .incr ();
104107
105- if (state .state .validators ().items .len > 0 )
108+ var validators = try state .state .validators ();
109+ if (try validators .length () > 0 )
106110 self .post_state_validators_nodes_populated_hit .incr ()
107111 else
108112 self .post_state_validators_nodes_populated_miss .incr ();
0 commit comments