Skip to content

Commit c985abd

Browse files
committed
fix: address reviews
1 parent 687b704 commit c985abd

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

beacon_chain/validators/action_tracker.nim

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,20 @@ proc registerPTCDuty*(
134134

135135
let newDuty = PTCDuty(slot: slot, validator_index: vidx)
136136

137-
if newDuty in tracker.ptcDuties:
138-
return
139-
140137
debug "Registering PTC duty", slot, vidx
141138
tracker.ptcDuties.incl(newDuty)
142139

143-
from std/sequtils import toSeq, anyIt
140+
from std/sequtils import anyIt, toSeq
144141

145142
func hasPTCDuty*(tracker: ActionTracker, slot: Slot): bool =
146143
tracker.ptcDuties.anyIt(it.slot == slot)
147144

148145
func getPTCDuties*(tracker: ActionTracker, slot: Slot): seq[ValidatorIndex] =
146+
var duties: seq[ValidatorIndex]
149147
for duty in tracker.ptcDuties:
150148
if duty.slot == slot:
151-
result.add(duty.validator_index)
149+
duties.add(duty.validator_index)
150+
duties
152151

153152
func aggregateSubnets*(tracker: ActionTracker, wallSlot: Slot): AttnetBits =
154153
var res: AttnetBits

beacon_chain/validators/beacon_validators.nim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,14 +1286,18 @@ proc registerPTCDuties(node: BeaconNode, epoch: Epoch) =
12861286
if node.dag.cfg.consensusForkAtEpoch(epoch) < ConsensusFork.Gloas:
12871287
return
12881288

1289-
let validatorIndices = toHashSet(toSeq(node.attachedValidators[].indices()))
1289+
let validatorIndices = block:
1290+
var res: HashSet[ValidatorIndex]
1291+
for idx in node.attachedValidators[].indices():
1292+
res.incl(idx)
1293+
res
12901294

12911295
withState(node.dag.headState):
12921296
when consensusFork >= ConsensusFork.Gloas:
1293-
var cache = new StateCache
1297+
var cache: StateCache
12941298

12951299
for slot in epoch.slots():
1296-
for validator_index in get_ptc(forkyState.data, slot, cache[]):
1300+
for validator_index in get_ptc(forkyState.data, slot, cache):
12971301
if validator_index in validatorIndices:
12981302
node.consensusManager[].actionTracker.registerPTCDuty(
12991303
slot, validator_index)

0 commit comments

Comments
 (0)