rm some unused code/imports ()

This commit is contained in:
tersec 2024-09-11 03:45:37 +00:00 committed by GitHub
parent 9f7a1361bd
commit 1503c7dffe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 27 deletions
beacon_chain

View File

@ -71,9 +71,6 @@ func len*(nodes: ProtoNodes): int =
func add(nodes: var ProtoNodes, node: ProtoNode) =
nodes.buf.add node
func isPreviousEpochJustified(self: ProtoArray): bool =
self.checkpoints.justified.epoch + 1 == self.currentEpoch
# Forward declarations
# ----------------------------------------------------------------------

View File

@ -9,13 +9,13 @@
# Uncategorized helper functions from the spec
import
std/[algorithm, hashes],
std/algorithm,
results,
eth/p2p/discoveryv5/[node],
./[helpers, digest],
./datatypes/[eip7594]
proc sortedColumnIndices*(columnsPerSubnet: ColumnIndex,
func sortedColumnIndices*(columnsPerSubnet: ColumnIndex,
subnetIds: HashSet[uint64]):
seq[ColumnIndex] =
var res: seq[ColumnIndex] = @[]
@ -26,8 +26,8 @@ proc sortedColumnIndices*(columnsPerSubnet: ColumnIndex,
res.sort
res
proc sortedColumnIndexList*(columnsPerSubnet: ColumnIndex,
subnetIds: HashSet[uint64]):
func sortedColumnIndexList*(columnsPerSubnet: ColumnIndex,
subnetIds: HashSet[uint64]):
List[ColumnIndex, NUMBER_OF_COLUMNS] =
var
res: seq[ColumnIndex]
@ -36,11 +36,10 @@ proc sortedColumnIndexList*(columnsPerSubnet: ColumnIndex,
let index = DATA_COLUMN_SIDECAR_SUBNET_COUNT * i + subnetId
res.add(ColumnIndex(index))
res.sort()
let list = List[ColumnIndex, NUMBER_OF_COLUMNS].init(res)
list
List[ColumnIndex, NUMBER_OF_COLUMNS].init(res)
proc get_custody_column_subnets*(node_id: NodeId,
custody_subnet_count: uint64):
func get_custody_column_subnets*(node_id: NodeId,
custody_subnet_count: uint64):
Result[HashSet[uint64], cstring] =
# Decouples the custody subnet computation part from
@ -50,7 +49,7 @@ proc get_custody_column_subnets*(node_id: NodeId,
if not (custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT):
return err("Eip7594: Custody subnet count exceeds the DATA_COLUMN_SIDECAR_SUBNET_COUNT")
var
var
subnet_ids: HashSet[uint64]
current_id = node_id
@ -61,11 +60,11 @@ proc get_custody_column_subnets*(node_id: NodeId,
let
current_id_bytes = current_id.toBytesLE()
hashed_current_id = eth2digest(current_id_bytes)
hashed_bytes[0..7] = hashed_current_id.data.toOpenArray(0,7)
let subnet_id = bytes_to_uint64(hashed_bytes) mod
let subnet_id = bytes_to_uint64(hashed_bytes) mod
DATA_COLUMN_SIDECAR_SUBNET_COUNT
subnet_ids.incl(subnet_id)
if current_id == UInt256.high.NodeId:
@ -76,30 +75,29 @@ proc get_custody_column_subnets*(node_id: NodeId,
ok(subnet_ids)
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#get_custody_columns
proc get_custody_columns*(node_id: NodeId,
custody_subnet_count: uint64):
func get_custody_columns*(node_id: NodeId,
custody_subnet_count: uint64):
seq[ColumnIndex] =
let
subnet_ids =
subnet_ids =
get_custody_column_subnets(node_id, custody_subnet_count).get
const
columns_per_subnet =
columns_per_subnet =
NUMBER_OF_COLUMNS div DATA_COLUMN_SIDECAR_SUBNET_COUNT
sortedColumnIndices(ColumnIndex(columns_per_subnet), subnet_ids)
func get_custody_column_list*(node_id: NodeId,
custody_subnet_count: uint64):
List[ColumnIndex, NUMBER_OF_COLUMNS] =
proc get_custody_column_list*(node_id: NodeId,
custody_subnet_count: uint64):
List[ColumnIndex, NUMBER_OF_COLUMNS] =
# Not in spec in the exact format, but it is useful in sorting custody columns
# Not in spec in the exact format, but it is useful in sorting custody columns
# before sending, data_column_sidecars_by_range requests
let
subnet_ids =
subnet_ids =
get_custody_column_subnets(node_id, custody_subnet_count).get
const
columns_per_subnet =
columns_per_subnet =
NUMBER_OF_COLUMNS div DATA_COLUMN_SIDECAR_SUBNET_COUNT
sortedColumnIndexList(ColumnIndex(columns_per_subnet), subnet_ids)