mechanical renamings

This commit is contained in:
Dustin Brody 2019-01-16 02:21:06 -08:00
parent 7608fd76a3
commit 1bf876f5c1
7 changed files with 37 additions and 37 deletions

View File

@ -197,7 +197,7 @@ proc proposeBlock(node: BeaconNode,
slot: slot,
parent_root: node.headBlockRoot,
randao_reveal: randaoReveal,
candidate_pow_receipt_root: node.mainchainMonitor.getBeaconBlockRef(),
deposit_root: node.mainchainMonitor.getBeaconBlockRef(),
signature: ValidatorSig(), # we need the rest of the block first!
body: blockBody)

View File

@ -207,22 +207,22 @@ func get_initial_beacon_state*(
var state = BeaconState(
# Misc
slot: INITIAL_SLOT_NUMBER,
slot: GENESIS_SLOT,
genesis_time: genesis_time,
fork_data: ForkData(
pre_fork_version: INITIAL_FORK_VERSION,
post_fork_version: INITIAL_FORK_VERSION,
fork_slot: INITIAL_SLOT_NUMBER,
pre_fork_version: GENESIS_FORK_VERSION,
post_fork_version: GENESIS_FORK_VERSION,
fork_slot: GENESIS_SLOT,
),
validator_registry_latest_change_slot: INITIAL_SLOT_NUMBER,
validator_registry_latest_change_slot: GENESIS_SLOT,
validator_registry_exit_count: 0,
validator_registry_delta_chain_tip: ZERO_HASH,
# Finality
previous_justified_slot: INITIAL_SLOT_NUMBER,
justified_slot: INITIAL_SLOT_NUMBER,
finalized_slot: INITIAL_SLOT_NUMBER,
previous_justified_slot: GENESIS_SLOT,
justified_slot: GENESIS_SLOT,
finalized_slot: GENESIS_SLOT,
# PoW receipt root
processed_pow_receipt_root: processed_pow_receipt_root,
@ -233,7 +233,7 @@ func get_initial_beacon_state*(
let validator_index = process_deposit(
state,
deposit.deposit_data.deposit_input.pubkey,
deposit.deposit_data.value,
deposit.deposit_data.amount,
deposit.deposit_data.deposit_input.proof_of_possession,
deposit.deposit_data.deposit_input.withdrawal_credentials,
deposit.deposit_data.deposit_input.randao_commitment,
@ -245,7 +245,7 @@ func get_initial_beacon_state*(
# set initial committee shuffling
let
initial_shuffling =
get_new_shuffling(Eth2Digest(), state.validator_registry, 0)
get_shuffling(Eth2Digest(), state.validator_registry, 0)
# initial_shuffling + initial_shuffling in spec, but more ugly
for i, n in initial_shuffling:

View File

@ -89,8 +89,8 @@ const
# Initial values
INITIAL_FORK_VERSION* = 0'u64
INITIAL_SLOT_NUMBER* = 0'u64
GENESIS_FORK_VERSION* = 0'u64
GENESIS_SLOT* = 0'u64
ZERO_HASH* = Eth2Digest()
# Time constants
@ -213,7 +213,7 @@ type
DepositData* = object
deposit_input*: DepositInput
value*: uint64 ## Value in Gwei
amount*: uint64 ## Value in Gwei
timestamp*: uint64 # Timestamp from deposit contract
DepositInput* = object
@ -249,7 +249,7 @@ type
randao_reveal*: Eth2Digest ##\
## Proposer RANDAO reveal
candidate_pow_receipt_root*: Eth2Digest
deposit_root*: Eth2Digest
signature*: ValidatorSig ##\
## Proposer signature
@ -324,7 +324,7 @@ type
batched_block_roots*: seq[Eth2Digest]
processed_pow_receipt_root*: Eth2Digest
candidate_pow_receipt_roots*: seq[CandidatePoWReceiptRootRecord]
deposit_roots*: seq[DepositRootVote]
ValidatorRecord* = object
pubkey*: ValidatorPubKey
@ -377,8 +377,8 @@ type
slot*: uint64 ##\
## When
CandidatePoWReceiptRootRecord* = object
candidate_pow_receipt_root*: Eth2Digest # Candidate PoW receipt root
DepositRootVote* = object
deposit_root*: Eth2Digest # Candidate PoW receipt root
vote_count*: uint64 # Vote count
PendingAttestationRecord* = object

View File

@ -31,10 +31,10 @@ func get_active_validator_indices*(validators: openArray[ValidatorRecord]): seq[
if is_active_validator(val):
result.add idx.Uint24
func get_new_shuffling*(seed: Eth2Digest,
validators: openArray[ValidatorRecord],
crosslinking_start_shard: uint64
): array[EPOCH_LENGTH, seq[ShardCommittee]] =
func get_shuffling*(seed: Eth2Digest,
validators: openArray[ValidatorRecord],
crosslinking_start_shard: uint64
): array[EPOCH_LENGTH, seq[ShardCommittee]] =
## Split up validators into groups at the start of every epoch,
## determining at what height they can make attestations and what shard they are making crosslinks for
## Implementation should do the following: http://vitalik.ca/files/ShuffleAndAssign.png

View File

@ -100,16 +100,16 @@ func processRandao(
return true
func processPoWReceiptRoot(state: var BeaconState, blck: BeaconBlock) =
func processDepositRoot(state: var BeaconState, blck: BeaconBlock) =
## https://github.com/ethereum/eth2.0-specs/blob/master/specs/core/0_beacon-chain.md#pow-receipt-root
for x in state.candidate_pow_receipt_roots.mitems():
if blck.candidate_pow_receipt_root == x.candidate_pow_receipt_root:
for x in state.deposit_roots.mitems():
if blck.deposit_root == x.deposit_root:
x.vote_count += 1
return
state.candidate_pow_receipt_roots.add CandidatePoWReceiptRootRecord(
candidate_pow_receipt_root: blck.candidate_pow_receipt_root,
state.deposit_roots.add DepositRootVote(
deposit_root: blck.deposit_root,
vote_count: 1
)
@ -362,7 +362,7 @@ proc processBlock(
warn("Randao reveal failed")
return false
processPoWReceiptRoot(state, blck)
processDepositRoot(state, blck)
if not processProposerSlashings(state, blck, flags):
return false
@ -565,11 +565,11 @@ func processEpoch(state: var BeaconState) =
block: # Receipt roots
if state.slot mod POW_RECEIPT_ROOT_VOTING_PERIOD == 0:
for x in state.candidate_pow_receipt_roots:
for x in state.deposit_roots:
if x.vote_count * 2 >= POW_RECEIPT_ROOT_VOTING_PERIOD:
state.processed_pow_receipt_root = x.candidate_pow_receipt_root
state.processed_pow_receipt_root = x.deposit_root
break
state.candidate_pow_receipt_roots = @[]
state.deposit_roots = @[]
block: # Justification
state.previous_justified_slot = state.justified_slot
@ -700,7 +700,7 @@ func processEpoch(state: var BeaconState) =
let next_start_shard =
(state.shard_committees_at_slots[^1][^1].shard + 1) mod SHARD_COUNT
for i, v in get_new_shuffling(
for i, v in get_shuffling(
state.latest_randao_mixes[
(state.slot - EPOCH_LENGTH) mod LATEST_RANDAO_MIXES_LENGTH],
state.validator_registry, next_start_shard):
@ -719,7 +719,7 @@ func processEpoch(state: var BeaconState) =
start_shard = state.shard_committees_at_slots[0][0].shard
if is_power_of_2(epochs_since_last_registry_change):
for i, v in get_new_shuffling(
for i, v in get_shuffling(
state.latest_randao_mixes[
(state.slot - EPOCH_LENGTH) mod LATEST_RANDAO_MIXES_LENGTH],
state.validator_registry, start_shard):

View File

@ -25,7 +25,7 @@ suite "Validators":
), 32*1024)
# TODO the shuffling looks really odd, probably buggy
let s = get_new_shuffling(Eth2Digest(), validators, 0)
let s = get_shuffling(Eth2Digest(), validators, 0)
check:
s.len == EPOCH_LENGTH
# 32k validators means 2 shards validated per slot - the aim is to get

View File

@ -67,7 +67,7 @@ func makeDeposit(i: int, flags: UpdateFlags): Deposit =
withdrawal_credentials: withdrawal_credentials,
randao_commitment: randao_commitment
),
value: MAX_DEPOSIT * GWEI_PER_ETH,
amount: MAX_DEPOSIT * GWEI_PER_ETH,
)
)
@ -78,7 +78,7 @@ func makeInitialDeposits*(
func makeGenesisBlock*(state: BeaconState): BeaconBlock =
BeaconBlock(
slot: INITIAL_SLOT_NUMBER,
slot: GENESIS_SLOT,
state_root: Eth2Digest(data: hash_tree_root(state))
)
@ -115,7 +115,7 @@ proc addBlock*(
parent_root: previous_block_root,
state_root: Eth2Digest(), # we need the new state first
randao_reveal: hackReveal(proposer),
candidate_pow_receipt_root: Eth2Digest(), # TODO
deposit_root: Eth2Digest(), # TODO
signature: ValidatorSig(), # we need the rest of the block first!
body: body
)