@@ -16,7 +16,6 @@ defmodule LambdaEthereumConsensus.Validator.Duties do
16
16
selection_proof: Bls . signature ( ) ,
17
17
signing_domain: Types . domain ( ) ,
18
18
subnet_id: Types . uint64 ( ) ,
19
- slot: Types . slot ( ) ,
20
19
validator_index: Types . validator_index ( ) ,
21
20
committee_index: Types . uint64 ( ) ,
22
21
committee_length: Types . uint64 ( ) ,
@@ -51,16 +50,13 @@ defmodule LambdaEthereumConsensus.Validator.Duties do
51
50
{ start_slot , end_slot } <- boundary_slots ( epoch ) do
52
51
committee_count_per_slot = Accessors . get_committee_count_per_slot ( state , epoch )
53
52
54
- start_slot .. end_slot
55
- |> Enum . flat_map ( fn slot ->
56
- 0 .. ( committee_count_per_slot - 1 )
57
- |> Enum . flat_map ( & compute_duties_per_committee ( state , epoch , slot , validators , & 1 ) )
58
- |> case do
59
- [ ] -> [ ]
60
- duties -> [ { slot , duties } ]
61
- end
62
- end )
63
- |> Map . new ( )
53
+ for slot <- start_slot .. end_slot ,
54
+ committee_i <- 0 .. ( committee_count_per_slot - 1 ) ,
55
+ reduce: % { } do
56
+ acc ->
57
+ new_duties = compute_duties_per_committee ( state , epoch , slot , validators , committee_i )
58
+ Map . update ( acc , slot , new_duties , & ( new_duties ++ & 1 ) )
59
+ end
64
60
end
65
61
end
66
62
@@ -71,15 +67,14 @@ defmodule LambdaEthereumConsensus.Validator.Duties do
71
67
validator = Map . get ( validators , validator_index ) ,
72
68
duty =
73
69
% {
74
- slot: slot ,
75
70
validator_index: validator_index ,
76
71
index_in_committee: index_in_committee ,
77
72
committee_length: length ( committee ) ,
78
73
committee_index: committee_index ,
79
74
attested?: false
80
75
}
81
- |> update_with_aggregation_duty ( state , validator . keystore . privkey )
82
- |> update_with_subnet_id ( state , epoch ) do
76
+ |> update_with_aggregation_duty ( state , slot , validator . keystore . privkey )
77
+ |> update_with_subnet_id ( state , epoch , slot ) do
83
78
duty
84
79
end
85
80
@@ -88,11 +83,11 @@ defmodule LambdaEthereumConsensus.Validator.Duties do
88
83
end
89
84
end
90
85
91
- defp update_with_aggregation_duty ( duty , beacon_state , privkey ) do
92
- proof = Utils . get_slot_signature ( beacon_state , duty . slot , privkey )
86
+ defp update_with_aggregation_duty ( duty , beacon_state , slot , privkey ) do
87
+ proof = Utils . get_slot_signature ( beacon_state , slot , privkey )
93
88
94
89
if Utils . aggregator? ( proof , duty . committee_length ) do
95
- epoch = Misc . compute_epoch_at_slot ( duty . slot )
90
+ epoch = Misc . compute_epoch_at_slot ( slot )
96
91
domain = Accessors . get_domain ( beacon_state , Constants . domain_aggregate_and_proof ( ) , epoch )
97
92
98
93
Map . put ( duty , :should_aggregate? , true )
@@ -103,11 +98,11 @@ defmodule LambdaEthereumConsensus.Validator.Duties do
103
98
end
104
99
end
105
100
106
- defp update_with_subnet_id ( duty , beacon_state , epoch ) do
101
+ defp update_with_subnet_id ( duty , beacon_state , epoch , slot ) do
107
102
committees_per_slot = Accessors . get_committee_count_per_slot ( beacon_state , epoch )
108
103
109
104
subnet_id =
110
- Utils . compute_subnet_for_attestation ( committees_per_slot , duty . slot , duty . committee_index )
105
+ Utils . compute_subnet_for_attestation ( committees_per_slot , slot , duty . committee_index )
111
106
112
107
Map . put ( duty , :subnet_id , subnet_id )
113
108
end
0 commit comments