Skip to content

Commit daf98e4

Browse files
arnetheduckzah
authored andcommitted
fix committee vs subnet confusion
1 parent 4959da7 commit daf98e4

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

beacon_chain/gossip_processing/eth2_processor.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ proc checkForPotentialDoppelganger(
188188
proc attestationValidator*(
189189
self: ref Eth2Processor,
190190
attestation: Attestation,
191-
committeeIndex: uint64,
191+
attestation_subnet: uint64,
192192
checksExpensive: bool = true): Future[ValidationResult] {.async.} =
193193
logScope:
194194
attestation = shortLog(attestation)
195-
committeeIndex
195+
attestation_subnet
196196

197197
let
198198
wallTime = self.getWallTime()
@@ -211,7 +211,7 @@ proc attestationValidator*(
211211
# Now proceed to validation
212212
let v = await self.attestationPool.validateAttestation(
213213
self.batchCrypto,
214-
attestation, wallTime, committeeIndex, checksExpensive)
214+
attestation, wallTime, attestation_subnet, checksExpensive)
215215
if v.isErr():
216216
debug "Dropping attestation", err = v.error()
217217
return v.error[0]

beacon_chain/gossip_processing/gossip_validation.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,16 @@ func check_aggregation_count(
134134

135135
func check_attestation_subnet(
136136
epochRef: EpochRef, attestation: Attestation,
137-
topicCommitteeIndex: uint64): Result[void, (ValidationResult, cstring)] =
137+
attestation_subnet: uint64): Result[void, (ValidationResult, cstring)] =
138138
let
139139
expectedSubnet =
140140
compute_subnet_for_attestation(
141141
get_committee_count_per_slot(epochRef),
142142
attestation.data.slot, attestation.data.index.CommitteeIndex)
143143

144-
if expectedSubnet != topicCommitteeIndex:
144+
if expectedSubnet != attestation_subnet:
145145
return err((ValidationResult.Reject, cstring(
146-
"Attestation's committee index not for the correct subnet")))
146+
"Attestation not on the correct subnet")))
147147

148148
ok()
149149

@@ -157,7 +157,7 @@ proc validateAttestation*(
157157
batchCrypto: ref BatchCrypto,
158158
attestation: Attestation,
159159
wallTime: BeaconTime,
160-
topicCommitteeIndex: uint64, checksExpensive: bool):
160+
attestation_subnet: uint64, checksExpensive: bool):
161161
Future[Result[tuple[attestingIndices: seq[ValidatorIndex], sig: CookedSig],
162162
(ValidationResult, cstring)]] {.async.} =
163163
# Some of the checks below have been reordered compared to the spec, to
@@ -227,7 +227,7 @@ proc validateAttestation*(
227227
# attestation.data.target.epoch), which may be pre-computed along with the
228228
# committee information for the signature check.
229229
block:
230-
let v = check_attestation_subnet(epochRef, attestation, topicCommitteeIndex) # [REJECT]
230+
let v = check_attestation_subnet(epochRef, attestation, attestation_subnet) # [REJECT]
231231
if v.isErr():
232232
return err(v.error)
233233

beacon_chain/nimbus_beacon_node.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,12 +1204,12 @@ proc installMessageValidators(node: BeaconNode) =
12041204
# subnets are subscribed to during any given epoch.
12051205
for it in 0'u64 ..< ATTESTATION_SUBNET_COUNT.uint64:
12061206
closureScope:
1207-
let ci = it
1207+
let attestation_subnet = it
12081208
node.network.addAsyncValidator(
1209-
getAttestationTopic(node.forkDigest, ci),
1209+
getAttestationTopic(node.forkDigest, attestation_subnet),
12101210
# This proc needs to be within closureScope; don't lift out of loop.
12111211
proc(attestation: Attestation): Future[ValidationResult] =
1212-
node.processor.attestationValidator(attestation, ci))
1212+
node.processor.attestationValidator(attestation, attestation_subnet))
12131213

12141214
node.network.addAsyncValidator(
12151215
getAggregateAndProofsTopic(node.forkDigest),

beacon_chain/rpc/validator_api.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ proc installValidatorApiHandlers*(rpcServer: RpcServer, node: BeaconNode) {.
122122
validator_pubkey: ValidatorPubKey, slot_signature: ValidatorSig) -> bool:
123123
debug "post_v1_validator_beacon_committee_subscriptions",
124124
committee_index, slot
125-
if committee_index.uint64 >= ATTESTATION_SUBNET_COUNT.uint64:
125+
if committee_index.uint64 >= MAX_COMMITTEES_PER_SLOT.uint64:
126126
raise newException(CatchableError,
127127
"Invalid committee index")
128128

beacon_chain/rpc/validator_rest_api.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
355355
return RestApiResponse.jsonError(Http503, BeaconNodeInSyncError)
356356

357357
for request in requests:
358-
if uint64(request.committee_index) >= uint64(ATTESTATION_SUBNET_COUNT):
358+
if uint64(request.committee_index) >= uint64(MAX_COMMITTEES_PER_SLOT):
359359
return RestApiResponse.jsonError(Http400,
360360
InvalidCommitteeIndexValueError)
361361
let validator_pubkey =

0 commit comments

Comments
 (0)