8
8
{.push raises : [].}
9
9
10
10
import chronos, chronicles
11
- import ssz_serialization/ types
11
+ import ssz_serialization/ [proofs, types]
12
12
import
13
13
../ validators/ action_tracker,
14
- ../ spec/ [forks, network, helpers, peerdas_helpers],
14
+ ../ spec/ [beaconstate, forks, network, helpers, peerdas_helpers],
15
15
../ networking/ eth2_network,
16
16
../ consensus_object_pools/ blockchain_dag,
17
17
../ consensus_object_pools/ block_dag,
18
18
../ consensus_object_pools/ data_column_quarantine,
19
- " ." / [request_manager, sync_manager, sync_protocol]
19
+ " ." / [request_manager, sync_manager, sync_protocol]
20
20
21
- from std/ algorithm import binarySearch, sort
21
+ from std/ algorithm import sort
22
+ from std/ sequtils import toSeq
22
23
from ../ beacon_clock import GetBeaconTimeFn
23
24
24
25
logScope: topics = " validator_custody"
@@ -65,17 +66,15 @@ proc init*(T: type ValidatorCustodyRef, network: Eth2Node,
65
66
dataColumnQuarantine: dataColumnQuarantine)
66
67
67
68
proc detectNewValidatorCustody (vcus: ValidatorCustodyRef ): seq [ColumnIndex ] =
68
- let
69
- headState = vcus.dag.headState
70
69
var
71
- res: seq [ ColumnIndex ]
70
+ cache = StateCache ()
72
71
diff_set: HashSet [ColumnIndex ]
73
- withState (headState):
72
+ withState (vcus.dag. headState):
74
73
when consensusFork >= ConsensusFork .Fulu :
75
- var validator_indices =
76
- get_active_validator_indices (forkyState.data, vcus.network. getBeaconTime ().slotOrZero.epoch )
74
+ let total_node_balance =
75
+ get_total_active_balance (forkyState.data, cache )
77
76
let vcustody =
78
- vcus.dag.cfg.get_validators_custody_requirement (forkyState, validator_indices )
77
+ vcus.dag.cfg.get_validators_custody_requirement (forkyState, total_node_balance )
79
78
80
79
let
81
80
newer_columns =
@@ -94,10 +93,7 @@ proc detectNewValidatorCustody(vcus: ValidatorCustodyRef): seq[ColumnIndex] =
94
93
diff_set = newer_column_set.difference (vcus.older_column_set)
95
94
vcus.newer_column_set = newer_column_set
96
95
97
- for i in diff_set.items ():
98
- res.add (i)
99
-
100
- res
96
+ toSeq (diff_set)
101
97
102
98
proc makeRefillList (vcus: ValidatorCustodyRef , diff: seq [ColumnIndex ]) =
103
99
let
0 commit comments