Validator pool update to use BLS domain

This commit is contained in:
mratsim 2019-09-08 14:09:01 -04:00 committed by Jacek Sieka
parent 2aee749ead
commit c619b9557a
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8
2 changed files with 12 additions and 7 deletions

View File

@ -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.} =

View File

@ -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: