sign the right attestation data
This commit is contained in:
parent
806836714a
commit
3e3ed79874
|
@ -28,9 +28,15 @@ proc getValidator*(pool: ValidatorPool,
|
||||||
proc signBlockProposal*(v: AttachedValidator, state: BeaconState, slot: Slot,
|
proc signBlockProposal*(v: AttachedValidator, state: BeaconState, slot: Slot,
|
||||||
blockRoot: Eth2Digest): Future[ValidatorSig] {.async.} =
|
blockRoot: Eth2Digest): Future[ValidatorSig] {.async.} =
|
||||||
if v.kind == inProcess:
|
if v.kind == inProcess:
|
||||||
|
# TODO this is an ugly hack to fake a delay and subsequent async reordering
|
||||||
|
# for the purpose of testing the external validator delay - to be
|
||||||
|
# replaced by something more sensible
|
||||||
await sleepAsync(chronos.milliseconds(1))
|
await sleepAsync(chronos.milliseconds(1))
|
||||||
result = bls_sign(v.privKey, blockRoot.data,
|
|
||||||
get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_of_slot(slot)))
|
let
|
||||||
|
domain =
|
||||||
|
get_domain(state, DOMAIN_BEACON_PROPOSER, compute_epoch_of_slot(slot))
|
||||||
|
result = bls_sign(v.privKey, blockRoot.data, domain)
|
||||||
else:
|
else:
|
||||||
# TODO:
|
# TODO:
|
||||||
# send RPC
|
# send RPC
|
||||||
|
@ -39,19 +45,18 @@ proc signBlockProposal*(v: AttachedValidator, state: BeaconState, slot: Slot,
|
||||||
proc signAttestation*(v: AttachedValidator,
|
proc signAttestation*(v: AttachedValidator,
|
||||||
attestation: AttestationData,
|
attestation: AttestationData,
|
||||||
state: BeaconState): Future[ValidatorSig] {.async.} =
|
state: BeaconState): Future[ValidatorSig] {.async.} =
|
||||||
# TODO: implement this
|
|
||||||
if v.kind == inProcess:
|
if v.kind == inProcess:
|
||||||
|
# TODO this is an ugly hack to fake a delay and subsequent async reordering
|
||||||
|
# for the purpose of testing the external validator delay - to be
|
||||||
|
# replaced by something more sensible
|
||||||
await sleepAsync(chronos.milliseconds(1))
|
await sleepAsync(chronos.milliseconds(1))
|
||||||
|
|
||||||
let attestationRoot = hash_tree_root(attestation)
|
let
|
||||||
# TODO: Avoid the allocations belows
|
attestationRoot = hash_tree_root(
|
||||||
var dataToSign = @(attestationRoot.data) & @[0'u8]
|
AttestationDataAndCustodyBit(data: attestation, custody_bit: false))
|
||||||
let domain = get_domain(
|
domain = get_domain(state, DOMAIN_ATTESTATION, attestation.target.epoch)
|
||||||
state,
|
|
||||||
DOMAIN_ATTESTATION,
|
result = bls_sign(v.privKey, attestationRoot.data, domain)
|
||||||
attestation.target.epoch
|
|
||||||
)
|
|
||||||
result = bls_sign(v.privKey, dataToSign, domain)
|
|
||||||
else:
|
else:
|
||||||
# TODO:
|
# TODO:
|
||||||
# send RPC
|
# send RPC
|
||||||
|
@ -59,10 +64,11 @@ proc signAttestation*(v: AttachedValidator,
|
||||||
|
|
||||||
func genRandaoReveal*(k: ValidatorPrivKey, state: BeaconState, slot: Slot):
|
func genRandaoReveal*(k: ValidatorPrivKey, state: BeaconState, slot: Slot):
|
||||||
ValidatorSig =
|
ValidatorSig =
|
||||||
# Off-by-one? I often get slot == state.slot but the check was "doAssert slot > state.slot" (Mamy)
|
let
|
||||||
doAssert slot >= state.slot, "input slot: " & $shortLog(slot) & " - beacon state slot: " & $shortLog(state.slot)
|
domain = get_domain(state, DOMAIN_RANDAO, compute_epoch_of_slot(slot))
|
||||||
bls_sign(k, hash_tree_root(compute_epoch_of_slot(slot).uint64).data,
|
root = hash_tree_root(compute_epoch_of_slot(slot).uint64).data
|
||||||
get_domain(state, DOMAIN_RANDAO, compute_epoch_of_slot(slot)))
|
|
||||||
|
bls_sign(k, root, domain)
|
||||||
|
|
||||||
func genRandaoReveal*(v: AttachedValidator, state: BeaconState, slot: Slot):
|
func genRandaoReveal*(v: AttachedValidator, state: BeaconState, slot: Slot):
|
||||||
ValidatorSig =
|
ValidatorSig =
|
||||||
|
|
Loading…
Reference in New Issue