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, slot: slot,
parent_root: node.headBlockRoot, parent_root: node.headBlockRoot,
randao_reveal: randaoReveal, 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! signature: ValidatorSig(), # we need the rest of the block first!
body: blockBody) body: blockBody)

View File

@ -207,22 +207,22 @@ func get_initial_beacon_state*(
var state = BeaconState( var state = BeaconState(
# Misc # Misc
slot: INITIAL_SLOT_NUMBER, slot: GENESIS_SLOT,
genesis_time: genesis_time, genesis_time: genesis_time,
fork_data: ForkData( fork_data: ForkData(
pre_fork_version: INITIAL_FORK_VERSION, pre_fork_version: GENESIS_FORK_VERSION,
post_fork_version: INITIAL_FORK_VERSION, post_fork_version: GENESIS_FORK_VERSION,
fork_slot: INITIAL_SLOT_NUMBER, 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_exit_count: 0,
validator_registry_delta_chain_tip: ZERO_HASH, validator_registry_delta_chain_tip: ZERO_HASH,
# Finality # Finality
previous_justified_slot: INITIAL_SLOT_NUMBER, previous_justified_slot: GENESIS_SLOT,
justified_slot: INITIAL_SLOT_NUMBER, justified_slot: GENESIS_SLOT,
finalized_slot: INITIAL_SLOT_NUMBER, finalized_slot: GENESIS_SLOT,
# PoW receipt root # PoW receipt root
processed_pow_receipt_root: processed_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( let validator_index = process_deposit(
state, state,
deposit.deposit_data.deposit_input.pubkey, 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.proof_of_possession,
deposit.deposit_data.deposit_input.withdrawal_credentials, deposit.deposit_data.deposit_input.withdrawal_credentials,
deposit.deposit_data.deposit_input.randao_commitment, deposit.deposit_data.deposit_input.randao_commitment,
@ -245,7 +245,7 @@ func get_initial_beacon_state*(
# set initial committee shuffling # set initial committee shuffling
let let
initial_shuffling = 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 # initial_shuffling + initial_shuffling in spec, but more ugly
for i, n in initial_shuffling: for i, n in initial_shuffling:

View File

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

View File

@ -31,7 +31,7 @@ func get_active_validator_indices*(validators: openArray[ValidatorRecord]): seq[
if is_active_validator(val): if is_active_validator(val):
result.add idx.Uint24 result.add idx.Uint24
func get_new_shuffling*(seed: Eth2Digest, func get_shuffling*(seed: Eth2Digest,
validators: openArray[ValidatorRecord], validators: openArray[ValidatorRecord],
crosslinking_start_shard: uint64 crosslinking_start_shard: uint64
): array[EPOCH_LENGTH, seq[ShardCommittee]] = ): array[EPOCH_LENGTH, seq[ShardCommittee]] =

View File

@ -100,16 +100,16 @@ func processRandao(
return true 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 ## 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(): for x in state.deposit_roots.mitems():
if blck.candidate_pow_receipt_root == x.candidate_pow_receipt_root: if blck.deposit_root == x.deposit_root:
x.vote_count += 1 x.vote_count += 1
return return
state.candidate_pow_receipt_roots.add CandidatePoWReceiptRootRecord( state.deposit_roots.add DepositRootVote(
candidate_pow_receipt_root: blck.candidate_pow_receipt_root, deposit_root: blck.deposit_root,
vote_count: 1 vote_count: 1
) )
@ -362,7 +362,7 @@ proc processBlock(
warn("Randao reveal failed") warn("Randao reveal failed")
return false return false
processPoWReceiptRoot(state, blck) processDepositRoot(state, blck)
if not processProposerSlashings(state, blck, flags): if not processProposerSlashings(state, blck, flags):
return false return false
@ -565,11 +565,11 @@ func processEpoch(state: var BeaconState) =
block: # Receipt roots block: # Receipt roots
if state.slot mod POW_RECEIPT_ROOT_VOTING_PERIOD == 0: 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: 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 break
state.candidate_pow_receipt_roots = @[] state.deposit_roots = @[]
block: # Justification block: # Justification
state.previous_justified_slot = state.justified_slot state.previous_justified_slot = state.justified_slot
@ -700,7 +700,7 @@ func processEpoch(state: var BeaconState) =
let next_start_shard = let next_start_shard =
(state.shard_committees_at_slots[^1][^1].shard + 1) mod SHARD_COUNT (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.latest_randao_mixes[
(state.slot - EPOCH_LENGTH) mod LATEST_RANDAO_MIXES_LENGTH], (state.slot - EPOCH_LENGTH) mod LATEST_RANDAO_MIXES_LENGTH],
state.validator_registry, next_start_shard): 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 start_shard = state.shard_committees_at_slots[0][0].shard
if is_power_of_2(epochs_since_last_registry_change): 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.latest_randao_mixes[
(state.slot - EPOCH_LENGTH) mod LATEST_RANDAO_MIXES_LENGTH], (state.slot - EPOCH_LENGTH) mod LATEST_RANDAO_MIXES_LENGTH],
state.validator_registry, start_shard): state.validator_registry, start_shard):

View File

@ -25,7 +25,7 @@ suite "Validators":
), 32*1024) ), 32*1024)
# TODO the shuffling looks really odd, probably buggy # TODO the shuffling looks really odd, probably buggy
let s = get_new_shuffling(Eth2Digest(), validators, 0) let s = get_shuffling(Eth2Digest(), validators, 0)
check: check:
s.len == EPOCH_LENGTH s.len == EPOCH_LENGTH
# 32k validators means 2 shards validated per slot - the aim is to get # 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, withdrawal_credentials: withdrawal_credentials,
randao_commitment: randao_commitment 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 = func makeGenesisBlock*(state: BeaconState): BeaconBlock =
BeaconBlock( BeaconBlock(
slot: INITIAL_SLOT_NUMBER, slot: GENESIS_SLOT,
state_root: Eth2Digest(data: hash_tree_root(state)) state_root: Eth2Digest(data: hash_tree_root(state))
) )
@ -115,7 +115,7 @@ proc addBlock*(
parent_root: previous_block_root, parent_root: previous_block_root,
state_root: Eth2Digest(), # we need the new state first state_root: Eth2Digest(), # we need the new state first
randao_reveal: hackReveal(proposer), randao_reveal: hackReveal(proposer),
candidate_pow_receipt_root: Eth2Digest(), # TODO deposit_root: Eth2Digest(), # TODO
signature: ValidatorSig(), # we need the rest of the block first! signature: ValidatorSig(), # we need the rest of the block first!
body: body body: body
) )