Skip to content

Commit 3dc502b

Browse files
committed
Address review comments.
1 parent d59af67 commit 3dc502b

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

beacon_chain/spec/peerdas_helpers.nim

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,11 @@ proc verify_data_column_sidecar_kzg_proofs*(sidecar: DataColumnSidecar):
486486

487487
ok()
488488

489-
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.3/specs/fulu/das-core.md#validator-custody
490-
proc get_validators_custody_requirement*(cfg: RuntimeConfig,
489+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/specs/fulu/validator.md#validator-custody
490+
func get_validators_custody_requirement*(cfg: RuntimeConfig,
491491
hstate: ForkyHashedBeaconState,
492-
validator_indices: openArray[ValidatorIndex]):
492+
total_node_balance: Gwei):
493493
uint64 =
494-
let state = hstate.data
495-
var total_node_balance: Gwei
496-
for index in validator_indices:
497-
total_node_balance += state.balances[index]
498494
let count = total_node_balance div BALANCE_PER_ADDITIONAL_CUSTODY_GROUP
499495
min(max(count.uint64, cfg.VALIDATOR_CUSTODY_REQUIREMENT),
500496
cfg.NUMBER_OF_CUSTODY_GROUPS.uint64)

beacon_chain/sync/validator_custody.nim

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
{.push raises: [].}
99

1010
import chronos, chronicles
11-
import ssz_serialization/types
11+
import ssz_serialization/[proofs, types]
1212
import
1313
../validators/action_tracker,
14-
../spec/[forks, network, helpers, peerdas_helpers],
14+
../spec/[beaconstate, forks, network, helpers, peerdas_helpers],
1515
../networking/eth2_network,
1616
../consensus_object_pools/blockchain_dag,
1717
../consensus_object_pools/block_dag,
1818
../consensus_object_pools/data_column_quarantine,
19-
"."/[request_manager, sync_manager, sync_protocol]
19+
"."/[request_manager, sync_manager, sync_protocol]
2020

21-
from std/algorithm import binarySearch, sort
21+
from std/algorithm import sort
22+
from std/sequtils import toSeq
2223
from ../beacon_clock import GetBeaconTimeFn
2324

2425
logScope: topics = "validator_custody"
@@ -65,17 +66,15 @@ proc init*(T: type ValidatorCustodyRef, network: Eth2Node,
6566
dataColumnQuarantine: dataColumnQuarantine)
6667

6768
proc detectNewValidatorCustody(vcus: ValidatorCustodyRef): seq[ColumnIndex] =
68-
let
69-
headState = vcus.dag.headState
7069
var
71-
res: seq[ColumnIndex]
70+
cache = StateCache()
7271
diff_set: HashSet[ColumnIndex]
73-
withState(headState):
72+
withState(vcus.dag.headState):
7473
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)
7776
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)
7978

8079
let
8180
newer_columns =
@@ -94,10 +93,7 @@ proc detectNewValidatorCustody(vcus: ValidatorCustodyRef): seq[ColumnIndex] =
9493
diff_set = newer_column_set.difference(vcus.older_column_set)
9594
vcus.newer_column_set = newer_column_set
9695

97-
for i in diff_set.items():
98-
res.add(i)
99-
100-
res
96+
toSeq(diff_set)
10197

10298
proc makeRefillList(vcus: ValidatorCustodyRef, diff: seq[ColumnIndex]) =
10399
let

0 commit comments

Comments
 (0)