fix committee vs subnet confusion
This commit is contained in:
parent
4959da78a8
commit
daf98e4330
|
@ -188,11 +188,11 @@ proc checkForPotentialDoppelganger(
|
|||
proc attestationValidator*(
|
||||
self: ref Eth2Processor,
|
||||
attestation: Attestation,
|
||||
committeeIndex: uint64,
|
||||
attestation_subnet: uint64,
|
||||
checksExpensive: bool = true): Future[ValidationResult] {.async.} =
|
||||
logScope:
|
||||
attestation = shortLog(attestation)
|
||||
committeeIndex
|
||||
attestation_subnet
|
||||
|
||||
let
|
||||
wallTime = self.getWallTime()
|
||||
|
@ -211,7 +211,7 @@ proc attestationValidator*(
|
|||
# Now proceed to validation
|
||||
let v = await self.attestationPool.validateAttestation(
|
||||
self.batchCrypto,
|
||||
attestation, wallTime, committeeIndex, checksExpensive)
|
||||
attestation, wallTime, attestation_subnet, checksExpensive)
|
||||
if v.isErr():
|
||||
debug "Dropping attestation", err = v.error()
|
||||
return v.error[0]
|
||||
|
|
|
@ -134,16 +134,16 @@ func check_aggregation_count(
|
|||
|
||||
func check_attestation_subnet(
|
||||
epochRef: EpochRef, attestation: Attestation,
|
||||
topicCommitteeIndex: uint64): Result[void, (ValidationResult, cstring)] =
|
||||
attestation_subnet: uint64): Result[void, (ValidationResult, cstring)] =
|
||||
let
|
||||
expectedSubnet =
|
||||
compute_subnet_for_attestation(
|
||||
get_committee_count_per_slot(epochRef),
|
||||
attestation.data.slot, attestation.data.index.CommitteeIndex)
|
||||
|
||||
if expectedSubnet != topicCommitteeIndex:
|
||||
if expectedSubnet != attestation_subnet:
|
||||
return err((ValidationResult.Reject, cstring(
|
||||
"Attestation's committee index not for the correct subnet")))
|
||||
"Attestation not on the correct subnet")))
|
||||
|
||||
ok()
|
||||
|
||||
|
@ -157,7 +157,7 @@ proc validateAttestation*(
|
|||
batchCrypto: ref BatchCrypto,
|
||||
attestation: Attestation,
|
||||
wallTime: BeaconTime,
|
||||
topicCommitteeIndex: uint64, checksExpensive: bool):
|
||||
attestation_subnet: uint64, checksExpensive: bool):
|
||||
Future[Result[tuple[attestingIndices: seq[ValidatorIndex], sig: CookedSig],
|
||||
(ValidationResult, cstring)]] {.async.} =
|
||||
# Some of the checks below have been reordered compared to the spec, to
|
||||
|
@ -227,7 +227,7 @@ proc validateAttestation*(
|
|||
# attestation.data.target.epoch), which may be pre-computed along with the
|
||||
# committee information for the signature check.
|
||||
block:
|
||||
let v = check_attestation_subnet(epochRef, attestation, topicCommitteeIndex) # [REJECT]
|
||||
let v = check_attestation_subnet(epochRef, attestation, attestation_subnet) # [REJECT]
|
||||
if v.isErr():
|
||||
return err(v.error)
|
||||
|
||||
|
|
|
@ -1204,12 +1204,12 @@ proc installMessageValidators(node: BeaconNode) =
|
|||
# subnets are subscribed to during any given epoch.
|
||||
for it in 0'u64 ..< ATTESTATION_SUBNET_COUNT.uint64:
|
||||
closureScope:
|
||||
let ci = it
|
||||
let attestation_subnet = it
|
||||
node.network.addAsyncValidator(
|
||||
getAttestationTopic(node.forkDigest, ci),
|
||||
getAttestationTopic(node.forkDigest, attestation_subnet),
|
||||
# This proc needs to be within closureScope; don't lift out of loop.
|
||||
proc(attestation: Attestation): Future[ValidationResult] =
|
||||
node.processor.attestationValidator(attestation, ci))
|
||||
node.processor.attestationValidator(attestation, attestation_subnet))
|
||||
|
||||
node.network.addAsyncValidator(
|
||||
getAggregateAndProofsTopic(node.forkDigest),
|
||||
|
|
|
@ -122,7 +122,7 @@ proc installValidatorApiHandlers*(rpcServer: RpcServer, node: BeaconNode) {.
|
|||
validator_pubkey: ValidatorPubKey, slot_signature: ValidatorSig) -> bool:
|
||||
debug "post_v1_validator_beacon_committee_subscriptions",
|
||||
committee_index, slot
|
||||
if committee_index.uint64 >= ATTESTATION_SUBNET_COUNT.uint64:
|
||||
if committee_index.uint64 >= MAX_COMMITTEES_PER_SLOT.uint64:
|
||||
raise newException(CatchableError,
|
||||
"Invalid committee index")
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
return RestApiResponse.jsonError(Http503, BeaconNodeInSyncError)
|
||||
|
||||
for request in requests:
|
||||
if uint64(request.committee_index) >= uint64(ATTESTATION_SUBNET_COUNT):
|
||||
if uint64(request.committee_index) >= uint64(MAX_COMMITTEES_PER_SLOT):
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
InvalidCommitteeIndexValueError)
|
||||
let validator_pubkey =
|
||||
|
|
Loading…
Reference in New Issue