diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 622c591a2..cb1eeebb3 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -345,12 +345,13 @@ proc updateHead(node: BeaconNode, slot: Slot): BlockRef = newHead proc sendAttestation(node: BeaconNode, + state: BeaconState, validator: AttachedValidator, attestationData: AttestationData, committeeLen: int, indexInCommittee: int) {.async.} = let - validatorSignature = await validator.signAttestation(attestationData) + validatorSignature = await validator.signAttestation(attestationData, state) var aggregationBits = CommitteeValidatorsBits.init(committeeLen) aggregationBits.raiseBit indexInCommittee @@ -577,9 +578,9 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) = let ad = makeAttestationData(state, shard, blck.root) attestations.add((ad, committee.len, i, validator)) - for a in attestations: - traceAsyncErrors sendAttestation( - node, a.validator, a.data, a.committeeLen, a.indexInCommittee) + for a in attestations: + traceAsyncErrors sendAttestation( + node, state, a.validator, a.data, a.committeeLen, a.indexInCommittee) proc handleProposal(node: BeaconNode, head: BlockRef, slot: Slot): Future[BlockRef] {.async.} = diff --git a/beacon_chain/validator_pool.nim b/beacon_chain/validator_pool.nim index af6f1848c..f64a0ffe2 100644 --- a/beacon_chain/validator_pool.nim +++ b/beacon_chain/validator_pool.nim @@ -37,7 +37,8 @@ proc signBlockProposal*(v: AttachedValidator, state: BeaconState, slot: Slot, discard proc signAttestation*(v: AttachedValidator, - attestation: AttestationData): Future[ValidatorSig] {.async.} = + attestation: AttestationData, + state: BeaconState): Future[ValidatorSig] {.async.} = # TODO: implement this if v.kind == inProcess: await sleepAsync(chronos.milliseconds(1)) @@ -45,8 +46,11 @@ proc signAttestation*(v: AttachedValidator, let attestationRoot = hash_tree_root(attestation) # TODO: Avoid the allocations belows var dataToSign = @(attestationRoot.data) & @[0'u8] - # TODO: Use `domain` here - let domain = 0'u64 + let domain = get_domain( + state, + DOMAIN_ATTESTATION, + attestation.target.epoch + ) result = bls_sign(v.privKey, dataToSign, domain) else: # TODO: