mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-23 19:58:22 +00:00
0.11.1 beacon chain spec update (#836)
* initial 0.11.1 spec commit; no test regressions and finalizes in eth2_network_simulation * with BLS 0.10/0.11 available, stop skipping attester slashing, proposer slashing, and voluntary exist operations fixture tests * switch param orders to group state.{fork, genesis_validators_root}; bump spec/datatypes spec version for network purposes * mark attestation construction and broadcast and some minimal/mainnet constants as 0.11.1-compatible; remove phase 1 sharding constants from minimal which don't exist in that preset
This commit is contained in:
parent
b44ba24142
commit
f5f939bd31
@ -51,7 +51,7 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
+ Attestation topics OK
|
||||
```
|
||||
OK: 1/1 Fail: 0/1 Skip: 0/1
|
||||
## Official - 0.11.0 - constants & config [Preset: mainnet]
|
||||
## Official - 0.11.1 - constants & config [Preset: mainnet]
|
||||
```diff
|
||||
+ BASE_REWARD_FACTOR 64 [Preset: mainnet] OK
|
||||
+ BLS_WITHDRAWAL_PREFIX "0x00" [Preset: mainnet] OK
|
||||
|
@ -78,7 +78,7 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
+ Attestation topics OK
|
||||
```
|
||||
OK: 1/1 Fail: 0/1 Skip: 0/1
|
||||
## Official - 0.11.0 - constants & config [Preset: minimal]
|
||||
## Official - 0.11.1 - constants & config [Preset: minimal]
|
||||
```diff
|
||||
+ BASE_REWARD_FACTOR 64 [Preset: minimal] OK
|
||||
+ BLS_WITHDRAWAL_PREFIX "0x00" [Preset: minimal] OK
|
||||
|
@ -45,6 +45,7 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
+ [Invalid] after_epoch_slots OK
|
||||
+ [Invalid] bad_source_root OK
|
||||
+ [Invalid] before_inclusion_delay OK
|
||||
+ [Invalid] empty_aggregation_bits OK
|
||||
+ [Invalid] future_target_epoch OK
|
||||
+ [Invalid] invalid_attestation_signature OK
|
||||
+ [Invalid] invalid_current_source_root OK
|
||||
@ -58,7 +59,6 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
+ [Invalid] too_many_aggregation_bits OK
|
||||
+ [Invalid] wrong_index_for_committee_signature OK
|
||||
+ [Invalid] wrong_index_for_slot OK
|
||||
+ [Valid] empty_aggregation_bits OK
|
||||
+ [Valid] success OK
|
||||
+ [Valid] success_multi_proposer_index_iterations OK
|
||||
+ [Valid] success_previous_epoch OK
|
||||
|
@ -45,6 +45,7 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
+ [Invalid] after_epoch_slots OK
|
||||
+ [Invalid] bad_source_root OK
|
||||
+ [Invalid] before_inclusion_delay OK
|
||||
+ [Invalid] empty_aggregation_bits OK
|
||||
+ [Invalid] future_target_epoch OK
|
||||
+ [Invalid] invalid_attestation_signature OK
|
||||
+ [Invalid] invalid_current_source_root OK
|
||||
@ -58,7 +59,6 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
+ [Invalid] too_many_aggregation_bits OK
|
||||
+ [Invalid] wrong_index_for_committee_signature OK
|
||||
+ [Invalid] wrong_index_for_slot OK
|
||||
+ [Valid] empty_aggregation_bits OK
|
||||
+ [Valid] success OK
|
||||
+ [Valid] success_multi_proposer_index_iterations OK
|
||||
+ [Valid] success_previous_epoch OK
|
||||
|
@ -1,6 +1,6 @@
|
||||
FixtureSSZConsensus-mainnet
|
||||
===
|
||||
## Official - 0.11.0 - SSZ consensus objects [Preset: mainnet]
|
||||
## Official - 0.11.1 - SSZ consensus objects [Preset: mainnet]
|
||||
```diff
|
||||
+ Testing AggregateAndProof OK
|
||||
+ Testing Attestation OK
|
||||
|
@ -1,6 +1,6 @@
|
||||
FixtureSSZConsensus-minimal
|
||||
===
|
||||
## Official - 0.11.0 - SSZ consensus objects [Preset: minimal]
|
||||
## Official - 0.11.1 - SSZ consensus objects [Preset: minimal]
|
||||
```diff
|
||||
+ Testing AggregateAndProof OK
|
||||
+ Testing Attestation OK
|
||||
|
@ -308,7 +308,7 @@ proc getAttestationsForBlock*(
|
||||
|
||||
for a in slotData.attestations:
|
||||
var
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/validator.md#construct-attestation
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#construct-attestation
|
||||
attestation = Attestation(
|
||||
aggregation_bits: a.validations[0].aggregation_bits,
|
||||
data: a.data,
|
||||
|
@ -316,14 +316,15 @@ proc updateHead(node: BeaconNode): BlockRef =
|
||||
|
||||
proc sendAttestation(node: BeaconNode,
|
||||
fork: Fork,
|
||||
genesis_validators_root: Eth2Digest,
|
||||
validator: AttachedValidator,
|
||||
attestationData: AttestationData,
|
||||
committeeLen: int,
|
||||
indexInCommittee: int) {.async.} =
|
||||
logScope: pcs = "send_attestation"
|
||||
|
||||
let
|
||||
validatorSignature = await validator.signAttestation(attestationData, fork)
|
||||
let validatorSignature = await validator.signAttestation(attestationData,
|
||||
fork, genesis_validators_root)
|
||||
|
||||
var aggregationBits = CommitteeValidatorsBits.init(committeeLen)
|
||||
aggregationBits.setBit indexInCommittee
|
||||
@ -334,7 +335,7 @@ proc sendAttestation(node: BeaconNode,
|
||||
aggregation_bits: aggregationBits
|
||||
)
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/validator.md#broadcast-attestation
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#broadcast-attestation
|
||||
node.network.broadcast(
|
||||
getAttestationTopic(attestationData.index), attestation)
|
||||
|
||||
@ -384,7 +385,7 @@ proc proposeBlock(node: BeaconNode,
|
||||
let message = makeBeaconBlock(
|
||||
state,
|
||||
head.root,
|
||||
validator.genRandaoReveal(state.fork, slot),
|
||||
validator.genRandaoReveal(state.fork, state.genesis_validators_root, slot),
|
||||
eth1data,
|
||||
Eth2Digest(),
|
||||
node.attestationPool.getAttestationsForBlock(state),
|
||||
@ -400,8 +401,8 @@ proc proposeBlock(node: BeaconNode,
|
||||
let blockRoot = hash_tree_root(newBlock.message)
|
||||
|
||||
# Careful, state no longer valid after here because of the await..
|
||||
newBlock.signature =
|
||||
await validator.signBlockProposal(state.fork, slot, blockRoot)
|
||||
newBlock.signature = await validator.signBlockProposal(
|
||||
state.fork, state.genesis_validators_root, slot, blockRoot)
|
||||
|
||||
(blockRoot, newBlock)
|
||||
|
||||
@ -556,7 +557,8 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
|
||||
|
||||
for a in attestations:
|
||||
traceAsyncErrors sendAttestation(
|
||||
node, state.fork, a.validator, a.data, a.committeeLen, a.indexInCommittee)
|
||||
node, state.fork, state.genesis_validators_root, a.validator, a.data,
|
||||
a.committeeLen, a.indexInCommittee)
|
||||
|
||||
proc handleProposal(node: BeaconNode, head: BlockRef, slot: Slot):
|
||||
Future[BlockRef] {.async.} =
|
||||
|
@ -286,12 +286,12 @@ func get_block_root*(state: BeaconState, epoch: Epoch): Eth2Digest =
|
||||
# Return the block root at the start of a recent ``epoch``.
|
||||
get_block_root_at_slot(state, compute_start_slot_at_epoch(epoch))
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/specs/phase0/beacon-chain.md#get_total_balance
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#get_total_balance
|
||||
func get_total_balance*(state: BeaconState, validators: auto): Gwei =
|
||||
## Return the combined effective balance of the ``indices``. (1 Gwei minimum
|
||||
## to avoid divisions by zero.)
|
||||
## Return the combined effective balance of the ``indices``.
|
||||
## ``EFFECTIVE_BALANCE_INCREMENT`` Gwei minimum to avoid divisions by zero.
|
||||
## Math safe up to ~10B ETH, afterwhich this overflows uint64.
|
||||
max(1'u64,
|
||||
max(EFFECTIVE_BALANCE_INCREMENT,
|
||||
foldl(validators, a + state.validators[b].effective_balance, 0'u64)
|
||||
)
|
||||
|
||||
@ -365,7 +365,7 @@ proc process_registry_updates*(state: var BeaconState) {.nbench.}=
|
||||
validator.activation_epoch =
|
||||
compute_activation_exit_epoch(get_current_epoch(state))
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.4/specs/core/0_beacon-chain.md#is_valid_indexed_attestation
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
||||
proc is_valid_indexed_attestation*(
|
||||
state: BeaconState, indexed_attestation: IndexedAttestation,
|
||||
flags: UpdateFlags): bool =
|
||||
@ -381,7 +381,6 @@ proc is_valid_indexed_attestation*(
|
||||
return false
|
||||
|
||||
# Verify indices are sorted and unique
|
||||
# TODO but why? this is a local artifact
|
||||
if indices != sorted(indices, system.cmp):
|
||||
notice "indexed attestation: indices not sorted"
|
||||
return false
|
||||
@ -436,7 +435,7 @@ func get_indexed_attestation(state: BeaconState, attestation: Attestation,
|
||||
signature: attestation.signature
|
||||
)
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/beacon-chain.md#attestations
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/specs/phase0/beacon-chain.md#attestations
|
||||
proc check_attestation*(
|
||||
state: BeaconState, attestation: Attestation, flags: UpdateFlags,
|
||||
stateCache: var StateCache): bool =
|
||||
|
@ -57,7 +57,7 @@ else:
|
||||
loadCustomPreset const_preset
|
||||
|
||||
const
|
||||
SPEC_VERSION* = "0.11.0" ## \
|
||||
SPEC_VERSION* = "0.11.1" ## \
|
||||
## Spec version we're aiming to be compatible with, right now
|
||||
|
||||
GENESIS_EPOCH* = (GENESIS_SLOT.uint64 div SLOTS_PER_EPOCH).Epoch ##\
|
||||
|
@ -149,25 +149,21 @@ func compute_domain*(
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/beacon-chain.md#get_domain
|
||||
func get_domain*(
|
||||
fork: Fork, domain_type: DomainType, epoch: Epoch): Domain =
|
||||
fork: Fork, domain_type: DomainType, epoch: Epoch, genesis_validators_root: Eth2Digest): Domain =
|
||||
## Return the signature domain (fork version concatenated with domain type)
|
||||
## of a message.
|
||||
let
|
||||
fork_version =
|
||||
if epoch < fork.epoch:
|
||||
fork.previous_version
|
||||
else:
|
||||
fork.current_version
|
||||
compute_domain(domain_type, fork_version)
|
||||
let fork_version =
|
||||
if epoch < fork.epoch:
|
||||
fork.previous_version
|
||||
else:
|
||||
fork.current_version
|
||||
compute_domain(domain_type, fork_version, genesis_validators_root)
|
||||
|
||||
func get_domain*(
|
||||
state: BeaconState, domain_type: DomainType, message_epoch: Epoch): Domain =
|
||||
state: BeaconState, domain_type: DomainType, epoch: Epoch): Domain =
|
||||
## Return the signature domain (fork version concatenated with domain type)
|
||||
## of a message.
|
||||
get_domain(state.fork, domain_type, message_epoch)
|
||||
|
||||
func get_domain*(state: BeaconState, domain_type: DomainType): Domain =
|
||||
get_domain(state, domain_type, get_current_epoch(state))
|
||||
get_domain(state.fork, domain_type, epoch, state. genesis_validators_root)
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/specs/phase0/beacon-chain.md#compute_signing_root
|
||||
func compute_signing_root*(ssz_object: auto, domain: Domain): Eth2Digest =
|
||||
|
@ -56,7 +56,7 @@ const
|
||||
|
||||
# Gwei values
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/configs/mainnet.yaml#L52
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/configs/mainnet.yaml#L58
|
||||
|
||||
MIN_DEPOSIT_AMOUNT* = 2'u64^0 * 10'u64^9 ##\
|
||||
## Minimum amounth of ETH that can be deposited in one call - deposits can
|
||||
|
@ -71,7 +71,7 @@ const
|
||||
|
||||
# Time parameters
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/configs/minimal.yaml#L71
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/configs/minimal.yaml#L77
|
||||
# Changed: Faster to spin up testnets, but does not give validator
|
||||
# reasonable warning time for genesis
|
||||
MIN_GENESIS_DELAY* = 300
|
||||
@ -178,16 +178,6 @@ const
|
||||
MIN_GASPRICE* = 32 # Gwei
|
||||
GASPRICE_ADJUSTMENT_COEFFICIENT* = 8
|
||||
|
||||
# Phase 1 - Sharding
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/configs/minimal.yaml#L157
|
||||
# TODO those are included in minimal.yaml but not mainnet.yaml
|
||||
# Why?
|
||||
SHARD_SLOTS_PER_BEACON_SLOT* = 2 # spec: SHARD_SLOTS_PER_EPOCH
|
||||
EPOCHS_PER_SHARD_PERIOD* = 4
|
||||
PHASE_1_FORK_EPOCH* = 8
|
||||
PHASE_1_FORK_SLOT* = 64
|
||||
|
||||
# Phase 1 - Custody game
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase1/custody-game.md#constants
|
||||
|
@ -108,7 +108,8 @@ proc process_randao(
|
||||
let proposer = addr state.validators[proposer_index.get]
|
||||
|
||||
# Verify that the provided randao value is valid
|
||||
let signing_root = compute_signing_root(epoch, get_domain(state, DOMAIN_RANDAO))
|
||||
let signing_root = compute_signing_root(
|
||||
epoch, get_domain(state, DOMAIN_RANDAO, get_current_epoch(state)))
|
||||
if skipBLSValidation notin flags:
|
||||
if not blsVerify(proposer.pubkey, signing_root.data, body.randao_reveal):
|
||||
notice "Randao mismatch", proposer_pubkey = shortLog(proposer.pubkey),
|
||||
@ -481,42 +482,47 @@ proc makeBeaconBlock*(
|
||||
|
||||
some(blck)
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/specs/phase0/validator.md
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#aggregation-selection
|
||||
func get_slot_signature*(
|
||||
fork: Fork, slot: Slot, privkey: ValidatorPrivKey): ValidatorSig =
|
||||
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
||||
privkey: ValidatorPrivKey): ValidatorSig =
|
||||
let
|
||||
domain =
|
||||
get_domain(fork, DOMAIN_SELECTION_PROOF, compute_epoch_at_slot(slot))
|
||||
domain = get_domain(fork, DOMAIN_SELECTION_PROOF,
|
||||
compute_epoch_at_slot(slot), genesis_validators_root)
|
||||
signing_root = compute_signing_root(slot, domain)
|
||||
|
||||
blsSign(privKey, signing_root.data)
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/specs/phase0/validator.md
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#randao-reveal
|
||||
func get_epoch_signature*(
|
||||
fork: Fork, slot: Slot, privkey: ValidatorPrivKey): ValidatorSig =
|
||||
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
||||
privkey: ValidatorPrivKey): ValidatorSig =
|
||||
let
|
||||
domain =
|
||||
get_domain(fork, DOMAIN_RANDAO, compute_epoch_at_slot(slot))
|
||||
domain = get_domain(fork, DOMAIN_RANDAO, compute_epoch_at_slot(slot),
|
||||
genesis_validators_root)
|
||||
signing_root = compute_signing_root(compute_epoch_at_slot(slot), domain)
|
||||
|
||||
blsSign(privKey, signing_root.data)
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/specs/phase0/validator.md
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#signature
|
||||
func get_block_signature*(
|
||||
fork: Fork, slot: Slot, root: Eth2Digest, privkey: ValidatorPrivKey): ValidatorSig =
|
||||
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
||||
root: Eth2Digest, privkey: ValidatorPrivKey): ValidatorSig =
|
||||
let
|
||||
domain =
|
||||
get_domain(fork, DOMAIN_BEACON_PROPOSER, compute_epoch_at_slot(slot))
|
||||
domain = get_domain(fork, DOMAIN_BEACON_PROPOSER,
|
||||
compute_epoch_at_slot(slot), genesis_validators_root)
|
||||
signing_root = compute_signing_root(root, domain)
|
||||
|
||||
blsSign(privKey, signing_root.data)
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/specs/phase0/validator.md
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#aggregate-signature
|
||||
func get_attestation_signature*(
|
||||
fork: Fork, attestation: AttestationData, privkey: ValidatorPrivKey): ValidatorSig =
|
||||
fork: Fork, genesis_validators_root: Eth2Digest, attestation: AttestationData,
|
||||
privkey: ValidatorPrivKey): ValidatorSig =
|
||||
let
|
||||
attestationRoot = hash_tree_root(attestation)
|
||||
domain = get_domain(fork, DOMAIN_BEACON_ATTESTER, attestation.target.epoch)
|
||||
domain = get_domain(fork, DOMAIN_BEACON_ATTESTER,
|
||||
attestation.target.epoch, genesis_validators_root)
|
||||
signing_root = compute_signing_root(attestationRoot, domain)
|
||||
|
||||
blsSign(privKey, signing_root.data)
|
||||
|
@ -242,7 +242,7 @@ func get_base_reward(state: BeaconState, index: ValidatorIndex,
|
||||
effective_balance * BASE_REWARD_FACTOR div
|
||||
integer_squareroot(total_balance) div BASE_REWARDS_PER_EPOCH
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
||||
func get_attestation_deltas(state: BeaconState, stateCache: var StateCache):
|
||||
tuple[a: seq[Gwei], b: seq[Gwei]] {.nbench.}=
|
||||
let
|
||||
@ -280,7 +280,7 @@ func get_attestation_deltas(state: BeaconState, stateCache: var StateCache):
|
||||
const increment = EFFECTIVE_BALANCE_INCREMENT
|
||||
let reward_numerator = get_base_reward(state, index, total_balance) *
|
||||
(attesting_balance div increment)
|
||||
rewards[index] = reward_numerator div (total_balance div increment)
|
||||
rewards[index] += reward_numerator div (total_balance div increment)
|
||||
else:
|
||||
penalties[index] += get_base_reward(state, index, total_balance)
|
||||
|
||||
|
@ -25,7 +25,8 @@ func getValidator*(pool: ValidatorPool,
|
||||
pool.validators.getOrDefault(validatorKey)
|
||||
|
||||
# TODO: Honest validator - https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/validator.md
|
||||
proc signBlockProposal*(v: AttachedValidator, fork: Fork, slot: Slot,
|
||||
proc signBlockProposal*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest, slot: Slot,
|
||||
blockRoot: Eth2Digest): Future[ValidatorSig] {.async.} =
|
||||
|
||||
if v.kind == inProcess:
|
||||
@ -34,30 +35,33 @@ proc signBlockProposal*(v: AttachedValidator, fork: Fork, slot: Slot,
|
||||
# replaced by something more sensible
|
||||
await sleepAsync(chronos.milliseconds(1))
|
||||
|
||||
result = get_block_signature(fork, slot, blockRoot, v.privKey)
|
||||
result = get_block_signature(
|
||||
fork, genesis_validators_root, slot, blockRoot, v.privKey)
|
||||
else:
|
||||
error "Unimplemented"
|
||||
quit 1
|
||||
|
||||
proc signAttestation*(v: AttachedValidator,
|
||||
attestation: AttestationData,
|
||||
fork: Fork): Future[ValidatorSig] {.async.} =
|
||||
fork: Fork, genesis_validators_root: Eth2Digest):
|
||||
Future[ValidatorSig] {.async.} =
|
||||
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))
|
||||
|
||||
result = get_attestation_signature(fork, attestation, v.privKey)
|
||||
result = get_attestation_signature(
|
||||
fork, genesis_validators_root, attestation, v.privKey)
|
||||
else:
|
||||
error "Unimplemented"
|
||||
quit 1
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/validator.md#randao-reveal
|
||||
func genRandaoReveal*(k: ValidatorPrivKey, fork: Fork, slot: Slot):
|
||||
ValidatorSig =
|
||||
get_epoch_signature(fork, slot, k)
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#randao-reveal
|
||||
func genRandaoReveal*(k: ValidatorPrivKey, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest, slot: Slot): ValidatorSig =
|
||||
get_epoch_signature(fork, genesis_validators_root, slot, k)
|
||||
|
||||
func genRandaoReveal*(v: AttachedValidator, fork: Fork, slot: Slot):
|
||||
ValidatorSig =
|
||||
genRandaoReveal(v.privKey, fork, slot)
|
||||
func genRandaoReveal*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest, slot: Slot): ValidatorSig =
|
||||
genRandaoReveal(v.privKey, fork, genesis_validators_root, slot)
|
||||
|
@ -66,7 +66,8 @@ proc signMockAttestation*(state: BeaconState, attestation: var Attestation) =
|
||||
var first_iter = true # Can't do while loop on hashset
|
||||
for validator_index in participants:
|
||||
let sig = get_attestation_signature(
|
||||
state.fork, attestation.data, MockPrivKeys[validator_index]
|
||||
state.fork, state.genesis_validators_root, attestation.data,
|
||||
MockPrivKeys[validator_index]
|
||||
)
|
||||
if first_iter:
|
||||
attestation.signature = sig
|
||||
|
@ -28,9 +28,10 @@ proc signMockBlockImpl(
|
||||
let privkey = MockPrivKeys[proposer_index]
|
||||
|
||||
signedBlock.message.body.randao_reveal = get_epoch_signature(
|
||||
state.fork, block_slot, privkey)
|
||||
state.fork, state.genesis_validators_root, block_slot, privkey)
|
||||
signedBlock.signature = get_block_signature(
|
||||
state.fork, block_slot, hash_tree_root(signedBlock.message), privkey)
|
||||
state.fork, state.genesis_validators_root, block_slot,
|
||||
hash_tree_root(signedBlock.message), privkey)
|
||||
|
||||
proc signMockBlock*(
|
||||
state: BeaconState,
|
||||
|
@ -36,7 +36,7 @@ proc readValue*(r: var JsonReader, a: var seq[byte]) {.inline.} =
|
||||
|
||||
const
|
||||
FixturesDir* = currentSourcePath.rsplit(DirSep, 1)[0] / ".." / ".." / "vendor" / "nim-eth2-scenarios"
|
||||
SszTestsDir* = FixturesDir/"tests-v0.11.0"
|
||||
SszTestsDir* = FixturesDir/"tests-v0.11.1"
|
||||
|
||||
proc parseTest*(path: string, Format: typedesc[Json or SSZ], T: typedesc): T =
|
||||
try:
|
||||
|
@ -19,7 +19,7 @@ import
|
||||
const
|
||||
SpecDir = currentSourcePath.rsplit(DirSep, 1)[0] /
|
||||
".."/".."/"beacon_chain"/"spec"
|
||||
Config = FixturesDir/"tests-v0.11.0"/const_preset/"config.yaml"
|
||||
Config = FixturesDir/"tests-v0.11.1"/const_preset/"config.yaml"
|
||||
|
||||
type
|
||||
CheckedType = SomeInteger or Slot or Epoch
|
||||
@ -122,5 +122,5 @@ proc checkConfig() =
|
||||
else:
|
||||
check: ConstsToCheck[constant] == value.getBiggestInt().uint64()
|
||||
|
||||
suiteReport "Official - 0.11.0 - constants & config " & preset():
|
||||
suiteReport "Official - 0.11.1 - constants & config " & preset():
|
||||
checkConfig()
|
||||
|
@ -32,8 +32,6 @@ proc runTest(identifier: string) =
|
||||
|
||||
var flags: UpdateFlags
|
||||
var prefix: string
|
||||
if not existsFile(testDir/"meta.yaml"):
|
||||
flags.incl skipBlsValidation
|
||||
if existsFile(testDir/"post.ssz"):
|
||||
prefix = "[Valid] "
|
||||
else:
|
||||
|
@ -32,8 +32,6 @@ proc runTest(identifier: string) =
|
||||
|
||||
var flags: UpdateFlags
|
||||
var prefix: string
|
||||
if not existsFile(testDir/"meta.yaml"):
|
||||
flags.incl skipBlsValidation
|
||||
if existsFile(testDir/"post.ssz"):
|
||||
prefix = "[Valid] "
|
||||
else:
|
||||
|
@ -32,8 +32,6 @@ proc runTest(identifier: string) =
|
||||
|
||||
var flags: UpdateFlags
|
||||
var prefix: string
|
||||
if not existsFile(testDir/"meta.yaml"):
|
||||
flags.incl skipBlsValidation
|
||||
if existsFile(testDir/"post.ssz"):
|
||||
prefix = "[Valid] "
|
||||
else:
|
||||
|
@ -32,8 +32,6 @@ proc runTest(identifier: string) =
|
||||
|
||||
var flags: UpdateFlags
|
||||
var prefix: string
|
||||
if not existsFile(testDir/"meta.yaml"):
|
||||
flags.incl skipBlsValidation
|
||||
if existsFile(testDir/"post.ssz"):
|
||||
prefix = "[Valid] "
|
||||
else:
|
||||
|
@ -25,7 +25,7 @@ import
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
const
|
||||
SSZDir = FixturesDir/"tests-v0.11.0"/const_preset/"phase0"/"ssz_static"
|
||||
SSZDir = FixturesDir/"tests-v0.11.1"/const_preset/"phase0"/"ssz_static"
|
||||
|
||||
type
|
||||
SSZHashTreeRoot = object
|
||||
@ -106,7 +106,7 @@ proc runSSZtests() =
|
||||
else:
|
||||
raise newException(ValueError, "Unsupported test: " & sszType)
|
||||
|
||||
suiteReport "Official - 0.11.0 - SSZ consensus objects " & preset():
|
||||
suiteReport "Official - 0.11.1 - SSZ consensus objects " & preset():
|
||||
runSSZtests()
|
||||
|
||||
summarizeLongTests("FixtureSSZConsensus")
|
||||
|
@ -23,7 +23,7 @@ import
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
const
|
||||
SSZDir = FixturesDir/"tests-v0.11.0"/"general"/"phase0"/"ssz_generic"
|
||||
SSZDir = FixturesDir/"tests-v0.11.1"/"general"/"phase0"/"ssz_generic"
|
||||
|
||||
type
|
||||
SSZHashTreeRoot = object
|
||||
|
@ -84,7 +84,8 @@ proc addTestBlock*(
|
||||
privKey = hackPrivKey(proposer)
|
||||
randao_reveal =
|
||||
if skipBlsValidation notin flags:
|
||||
privKey.genRandaoReveal(state.fork, state.slot)
|
||||
privKey.genRandaoReveal(
|
||||
state.fork, state.genesis_validators_root, state.slot)
|
||||
else:
|
||||
ValidatorSig()
|
||||
|
||||
@ -149,7 +150,8 @@ proc makeAttestation*(
|
||||
let
|
||||
sig =
|
||||
if skipBLSValidation notin flags:
|
||||
get_attestation_signature(state.fork, data, hackPrivKey(validator))
|
||||
get_attestation_signature(state.fork, state.genesis_validators_root,
|
||||
data, hackPrivKey(validator))
|
||||
else:
|
||||
ValidatorSig()
|
||||
|
||||
@ -203,7 +205,7 @@ proc makeFullAttestations*(
|
||||
aggregation_bits: CommitteeValidatorsBits.init(committee.len),
|
||||
data: data,
|
||||
signature: get_attestation_signature(
|
||||
state.fork, data,
|
||||
state.fork, state.genesis_validators_root, data,
|
||||
hackPrivKey(state.validators[committee[0]]))
|
||||
)
|
||||
# Aggregate the remainder
|
||||
@ -212,7 +214,7 @@ proc makeFullAttestations*(
|
||||
attestation.aggregation_bits.setBit j
|
||||
if skipBLSValidation notin flags:
|
||||
attestation.signature.aggregate(get_attestation_signature(
|
||||
state.fork, data,
|
||||
state.fork, state.genesis_validators_root, data,
|
||||
hackPrivKey(state.validators[committee[j]])
|
||||
))
|
||||
|
||||
|
2
vendor/nim-eth2-scenarios
vendored
2
vendor/nim-eth2-scenarios
vendored
@ -1 +1 @@
|
||||
Subproject commit b06d78d1d8c306a3cce80c391856f44bf7db6119
|
||||
Subproject commit 5326d824b1d91ea273095172512eb309f32e0c82
|
Loading…
x
Reference in New Issue
Block a user