diff --git a/beacon_chain/spec/datatypes/fulu.nim b/beacon_chain/spec/datatypes/fulu.nim index 1d63a7f2c2..8f2ad6d084 100644 --- a/beacon_chain/spec/datatypes/fulu.nim +++ b/beacon_chain/spec/datatypes/fulu.nim @@ -59,11 +59,19 @@ const # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/p2p-interface.md#configuration DATA_COLUMN_SIDECAR_SUBNET_COUNT* = 128 - # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/das-core.md#custody-setting + # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/fulu/das-core.md#custody-setting SAMPLES_PER_SLOT* = 8 CUSTODY_REQUIREMENT* = 4 NUMBER_OF_CUSTODY_GROUPS* = 128 + # Minimum number of custody groups an honest node with + # validators attached custodies and serves samples from + VALIDATOR_CUSTODY_REQUIREMENT* = 8 + + # Balance increment corresponding to one additional group to custody + # 2**5 * 10**9 (= 32,000,000,000) Gwei + BALANCE_PER_ADDITIONAL_CUSTODY_GROUP*: uint64 = 32000000000'u64 + # Number of columns in the network per custody group COLUMNS_PER_GROUP* = NUMBER_OF_COLUMNS div NUMBER_OF_CUSTODY_GROUPS diff --git a/beacon_chain/spec/peerdas_helpers.nim b/beacon_chain/spec/peerdas_helpers.nim index 578f22de05..a57c426658 100644 --- a/beacon_chain/spec/peerdas_helpers.nim +++ b/beacon_chain/spec/peerdas_helpers.nim @@ -342,3 +342,13 @@ proc verify_data_column_sidecar_kzg_proofs*(sidecar: DataColumnSidecar): return err("DataColumnSidecar: validation failed") ok() + +# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/fulu/das-core.md#validator-custody +func get_validators_custody_requirement*(state: fulu.BeaconState, + validator_indices: openArray[ValidatorIndex]): + uint64 = + var total_node_balance: Gwei + for index in validator_indices: + total_node_balance += state.balances[index] + let count = total_node_balance div BALANCE_PER_ADDITIONAL_CUSTODY_GROUP + min(max(count.uint64, VALIDATOR_CUSTODY_REQUIREMENT.uint64), NUMBER_OF_CUSTODY_GROUPS.uint64)