Skip to content

Commit 1b7293b

Browse files
committed
fix ssz and sig issues
1 parent 080adc5 commit 1b7293b

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

beacon_chain/gossip_processing/gossip_validation.nim

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import
1313
results,
1414
kzg4844/[kzg, kzg_abi],
1515
stew/byteutils,
16+
ssz_serialization/types as sszTypes,
1617
# Internals
1718
../spec/[
18-
beaconstate, state_transition_block, forks,
19+
beaconstate, state_transition_block, forks, datatypes/focil,
1920
helpers, network, signatures, peerdas_helpers, focil_helpers],
2021
../consensus_object_pools/[
2122
attestation_pool, blockchain_dag, blob_quarantine, block_quarantine,
@@ -1919,7 +1920,7 @@ proc validateInclusionList*(
19191920

19201921
# [IGNORE] The slot message.slot is equal to the current slot, or it is equal to the previous slot and the current time is less than ATTESTATION_DEADLINE seconds into the slot.
19211922
if message.slot == currentSlot - 1:
1922-
let slotStartTime = message.slot.start_time()
1923+
let slotStartTime = message.slot.start_beacon_time()
19231924
let currentTime = wallTime
19241925
if currentTime >= slotStartTime + ATTESTATION_DEADLINE:
19251926
return errIgnore("InclusionList: previous slot inclusion list received after deadline")
@@ -1928,10 +1929,11 @@ proc validateInclusionList*(
19281929
withState(dag.headState):
19291930
let committee = resolve_inclusion_list_committee(forkyState.data, message.slot)
19301931
# Note: We need to convert the HashSet to a sequence for hash_tree_root
1931-
var committeeSeq: seq[ValidatorIndex]
1932+
var committeeList: List[uint64, Limit INCLUSION_LIST_COMMITTEE_SIZE]
19321933
for validator in committee:
1933-
committeeSeq.add(validator)
1934-
let committeeRoot = hash_tree_root(committeeSeq)
1934+
if not committeeList.add(validator):
1935+
raiseAssert "Committee list overflowed its maximum size"
1936+
let committeeRoot = hash_tree_root(committeeList)
19351937
if committeeRoot != message.inclusion_list_committee_root:
19361938
return errIgnore("InclusionList: inclusion list committee root mismatch")
19371939

@@ -1949,7 +1951,9 @@ proc validateInclusionList*(
19491951
let sig =
19501952
if checkSignature:
19511953
withState(dag.headState):
1952-
let pubkey = forkyState.data.validators[message.validator_index].pubkeyData
1954+
let
1955+
pubkey = dag.validatorKey(message.validator_index).valueOr:
1956+
return dag.checkedReject("InclusionList: invalid validator index")
19531957
let deferredCrypto = batchCrypto.scheduleInclusionListCheck(
19541958
dag.forkAtEpoch(message.slot.epoch),
19551959
message, pubkey, signed_inclusion_list.signature)

beacon_chain/spec/datatypes/constants.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,3 @@ const
9090

9191
# https://github.com/ethereum/consensus-specs/blob/dev/specs/_features/eip7805/p2p-interface.md#configuration
9292
MAX_REQUEST_INCLUSION_LIST*: uint64 = 16 # 2**4
93-
INCLUSION_LIST_COMMITTEE_SIZE*: uint64 = 128

beacon_chain/spec/focil_helpers.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func is_valid_inclusion_list_signature*(
3939
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.2/specs/_features/eip7805/beacon-chain.md#new-get_inclusion_list_committee
4040
func resolve_inclusion_list_committee*(
4141
state: ForkyBeaconState,
42-
slot: Slot): HashSet[ValidatorIndex] =
42+
slot: Slot): HashSet[uint64] =
4343
## Return the inclusion list committee for the given slot
4444
let
4545
seed = get_seed(state, slot.epoch(), DOMAIN_INCLUSION_LIST_COMMITTEE)
@@ -50,15 +50,15 @@ func resolve_inclusion_list_committee*(
5050
end_i = start + INCLUSION_LIST_COMMITTEE_SIZE
5151
seq_len {.inject.} = indices.lenu64
5252

53-
var res: HashSet[ValidatorIndex]
53+
var res: HashSet[uint64]
5454
for i in 0..<INCLUSION_LIST_COMMITTEE_SIZE:
5555
let
5656
shuffledIdx = compute_shuffled_index(
57-
((start + i) mod seq_len).asUInt64,
57+
(start + i) mod seq_len,
5858
seq_len,
5959
seed)
6060

61-
res.incl indices[shuffledIdx]
61+
res.incl uint64(indices[shuffledIdx])
6262

6363
res
6464

0 commit comments

Comments
 (0)