From 4140b3b9d9c58ea57bbab3299e69c8862d9063a1 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Wed, 8 Jul 2020 22:36:26 +0200 Subject: [PATCH] update 29 spec refs to v0.12.1 --- beacon_chain/attestation_aggregation.nim | 4 +-- beacon_chain/block_pools/candidate_chains.nim | 2 +- beacon_chain/eth2_network.nim | 2 +- beacon_chain/spec/beaconstate.nim | 4 +-- beacon_chain/spec/helpers.nim | 12 +++---- beacon_chain/spec/presets/v0_12_1/mainnet.nim | 32 +++++++++---------- beacon_chain/spec/state_transition_block.nim | 4 +-- beacon_chain/validator_duties.nim | 2 +- beacon_chain/validator_pool.nim | 2 +- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/beacon_chain/attestation_aggregation.nim b/beacon_chain/attestation_aggregation.nim index a8b59355d..f406c1cc4 100644 --- a/beacon_chain/attestation_aggregation.nim +++ b/beacon_chain/attestation_aggregation.nim @@ -18,7 +18,7 @@ import logScope: topics = "att_aggr" -# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#aggregation-selection +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/validator.md#aggregation-selection func is_aggregator(state: BeaconState, slot: Slot, index: CommitteeIndex, slot_signature: ValidatorSig, cache: var StateCache): bool = let @@ -60,7 +60,7 @@ proc aggregate_attestations*( index: index.uint64, beacon_block_root: get_block_root_at_slot(state, slot)) - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#construct-aggregate + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/validator.md#construct-aggregate # TODO once EV goes in w/ refactoring of getAttestationsForBlock, pull out the getSlot version and use # it. This is incorrect. for attestation in getAttestationsForBlock(pool, state): diff --git a/beacon_chain/block_pools/candidate_chains.nim b/beacon_chain/block_pools/candidate_chains.nim index 3c7316128..c9b1d14aa 100644 --- a/beacon_chain/block_pools/candidate_chains.nim +++ b/beacon_chain/block_pools/candidate_chains.nim @@ -108,7 +108,7 @@ func getAncestorAt*(blck: BlockRef, slot: Slot): BlockRef = blck = blck.parent func get_ancestor*(blck: BlockRef, slot: Slot): BlockRef = - ## https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/fork-choice.md#get_ancestor + ## https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/fork-choice.md#get_ancestor ## Return ancestor at slot, or nil if queried block is older var blck = blck diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index e3d6ef51b..53de2af2b 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -189,7 +189,7 @@ const HandshakeTimeout = FaultOrError # Spec constants - # https://github.com/ethereum/eth2.0-specs/blob/dev/specs/networking/p2p-interface.md#eth-20-network-interaction-domains + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/p2p-interface.md#eth2-network-interaction-domains MAX_CHUNK_SIZE* = 1 * 1024 * 1024 # bytes GOSSIP_MAX_SIZE* = 1 * 1024 * 1024 # bytes TTFB_TIMEOUT* = 5.seconds diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index d9ed9d431..76a1b915a 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -439,7 +439,7 @@ func is_valid_indexed_attestation*( true -# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#get_attesting_indices +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#get_attesting_indices func get_attesting_indices*(state: BeaconState, data: AttestationData, bits: CommitteeValidatorsBits, @@ -691,7 +691,7 @@ func makeAttestationData*( doAssert slot.compute_epoch_at_slot == current_epoch - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/validator.md#attestation-data + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/validator.md#attestation-data AttestationData( slot: slot, index: committee_index, diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index ce33dae2a..0a9b123cd 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -56,7 +56,7 @@ func is_active_validator*(validator: Validator, epoch: Epoch): bool = ### Check if ``validator`` is active validator.activation_epoch <= epoch and epoch < validator.exit_epoch -# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#get_active_validator_indices +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#get_active_validator_indices func get_active_validator_indices*(state: BeaconState, epoch: Epoch): seq[ValidatorIndex] = # Return the sequence of active validator indices at ``epoch``. @@ -85,13 +85,13 @@ func get_committee_count_at_slot*(state: BeaconState, slot: Slot): uint64 = # Otherwise, get_beacon_committee(...) cannot access some committees. doAssert (SLOTS_PER_EPOCH * MAX_COMMITTEES_PER_SLOT).uint64 >= result -# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#get_current_epoch +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#get_current_epoch func get_current_epoch*(state: BeaconState): Epoch = # Return the current epoch. doAssert state.slot >= GENESIS_SLOT, $state.slot compute_epoch_at_slot(state.slot) -# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#get_randao_mix +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#get_randao_mix func get_randao_mix*(state: BeaconState, epoch: Epoch): Eth2Digest = ## Returns the randao mix at a recent ``epoch``. @@ -132,7 +132,7 @@ func int_to_bytes4*(x: uint64): array[4, byte] = result[2] = ((x shr 16) and 0xff).byte result[3] = ((x shr 24) and 0xff).byte -# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#compute_fork_data_root +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#compute_fork_data_root func compute_fork_data_root(current_version: Version, genesis_validators_root: Eth2Digest): Eth2Digest = # Return the 32-byte fork data root for the ``current_version`` and @@ -144,7 +144,7 @@ func compute_fork_data_root(current_version: Version, genesis_validators_root: genesis_validators_root )) -# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#compute_fork_digest +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#compute_fork_digest func compute_fork_digest*(current_version: Version, genesis_validators_root: Eth2Digest): ForkDigest = # Return the 4-byte fork digest for the ``current_version`` and @@ -194,7 +194,7 @@ func compute_signing_root*(ssz_object: auto, domain: Domain): Eth2Digest = ) hash_tree_root(domain_wrapped_object) -# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#get_seed +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#get_seed func get_seed*(state: BeaconState, epoch: Epoch, domain_type: DomainType): Eth2Digest = # Return the seed at ``epoch``. diff --git a/beacon_chain/spec/presets/v0_12_1/mainnet.nim b/beacon_chain/spec/presets/v0_12_1/mainnet.nim index 9e29e93fe..8095be665 100644 --- a/beacon_chain/spec/presets/v0_12_1/mainnet.nim +++ b/beacon_chain/spec/presets/v0_12_1/mainnet.nim @@ -20,7 +20,7 @@ type const # Misc # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L6 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L6 MAX_COMMITTEES_PER_SLOT* {.intdefine.} = 64 @@ -50,7 +50,7 @@ const # Gwei values # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L58 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.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 @@ -67,13 +67,13 @@ const # Initial values # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L70 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L70 GENESIS_FORK_VERSION* = [0'u8, 0'u8, 0'u8, 0'u8] BLS_WITHDRAWAL_PREFIX* = 0'u8 # Time parameters # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L77 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L77 GENESIS_DELAY* {.intdefine.} = 172800 # 172800 seconds (2 days) SECONDS_PER_SLOT* {.intdefine.} = 12'u64 # Compile with -d:SECONDS_PER_SLOT=1 for 12x faster slots @@ -100,8 +100,6 @@ const MIN_SEED_LOOKAHEAD* = 1 ##\ ## epochs (~6.4 minutes) - SHARD_COMMITTEE_PERIOD* = 256 # epochs (~27 hours) - MAX_SEED_LOOKAHEAD* = 4 ##\ ## epochs (~25.6 minutes) @@ -114,6 +112,8 @@ const MIN_VALIDATOR_WITHDRAWABILITY_DELAY* = 2'u64^8 ##\ ## epochs (~27 hours) + SHARD_COMMITTEE_PERIOD* = 256 # epochs (~27 hours) + MAX_EPOCHS_PER_CROSSLINK* = 2'u64^6 ##\ ## epochs (~7 hours) @@ -122,7 +122,7 @@ const # State vector lengths # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L105 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L105 EPOCHS_PER_HISTORICAL_VECTOR* = 65536 ##\ ## epochs (~0.8 years) @@ -137,7 +137,7 @@ const # Reward and penalty quotients # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L117 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L117 BASE_REWARD_FACTOR* = 2'u64^6 WHISTLEBLOWER_REWARD_QUOTIENT* = 2'u64^9 PROPOSER_REWARD_QUOTIENT* = 2'u64^3 @@ -146,7 +146,7 @@ const # Max operations per block # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L131 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L131 MAX_PROPOSER_SLASHINGS* = 2^4 MAX_ATTESTER_SLASHINGS* = 2^1 MAX_ATTESTATIONS* = 2^7 @@ -155,12 +155,12 @@ const # Fork choice # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L32 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L32 SAFE_SLOTS_TO_UPDATE_JUSTIFIED* = 8 # 96 seconds # Validators # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L38 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L38 ETH1_FOLLOW_DISTANCE* {.intdefine.} = 1024 # blocks ~ 4 hours TARGET_AGGREGATORS_PER_COMMITTEE* = 16 # validators RANDOM_SUBNETS_PER_VALIDATOR* = 1 # subnet @@ -168,14 +168,14 @@ const SECONDS_PER_ETH1_BLOCK* {.intdefine.} = 14 # (estimate from Eth1 mainnet) # Phase 1: Upgrade from Phase 0 - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L161 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L161 PHASE_1_FORK_VERSION* = 1 PHASE_1_GENESIS_SLOT* = 32 # [STUB] INITIAL_ACTIVE_SHARDS* = 64 # Phase 1: General # --------------------------------------------------------------- - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L166 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L168 MAX_SHARDS* = 1024 ONLINE_PERIOD* = 8 # epochs (~51 min) LIGHT_CLIENT_COMMITTEE_SIZE* = 128 @@ -191,7 +191,7 @@ const # Phase 1: Custody game # --------------------------------------------------------------- # Time parameters - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L199 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L199 RANDAO_PENALTY_EPOCHS* = 2 # epochs (12.8 minutes) EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS* = 16384 # epochs (~73 days) EPOCHS_PER_CUSTODY_PERIOD* = 2048 # epochs (~9 days) @@ -199,12 +199,12 @@ const MAX_REVEAL_LATENESS_DECREMENT* = 128 # epochs (~14 hours) # Max operations - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L211 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L211 MAX_CUSTODY_KEY_REVEALS* = 256 MAX_EARLY_DERIVED_SECRET_REVEALS* = 1 MAX_CUSTODY_SLASHINGS* = 1 # Reward and penalty quotients - # https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/configs/mainnet.yaml#L217 + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/configs/mainnet.yaml#L217 EARLY_DERIVED_SECRET_REVEAL_SLOT_REWARD_MULTIPLE* = 2 MINOR_REWARD_QUOTIENT* = 256 diff --git a/beacon_chain/spec/state_transition_block.nim b/beacon_chain/spec/state_transition_block.nim index af32e086a..260ee3f26 100644 --- a/beacon_chain/spec/state_transition_block.nim +++ b/beacon_chain/spec/state_transition_block.nim @@ -225,7 +225,7 @@ proc process_attester_slashing*( return err("Attester slashing: Trying to slash participant(s) twice") ok() -# https://github.com/ethereum/eth2.0-specs/blob/v0.9.4/specs/core/0_beacon-chain.md#voluntary-exits +# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#voluntary-exits proc process_voluntary_exit*( state: var BeaconState, signed_voluntary_exit: SignedVoluntaryExit, @@ -243,7 +243,7 @@ proc process_voluntary_exit*( if not is_active_validator(validator, get_current_epoch(state)): return err("Exit: validator not active") - # Verify the validator has not yet exited + # Verify exit has not been initiated if validator.exit_epoch != FAR_FUTURE_EPOCH: return err("Exit: validator has exited") diff --git a/beacon_chain/validator_duties.nim b/beacon_chain/validator_duties.nim index c20e34c01..4174adbe0 100644 --- a/beacon_chain/validator_duties.nim +++ b/beacon_chain/validator_duties.nim @@ -323,7 +323,7 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) = # We need to run attestations exactly for the slot that we're attesting to. # In case blocks went missing, this means advancing past the latest block # using empty slots as fillers. - # https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/specs/validator/0_beacon-chain-validator.md#validator-assignments + # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/validator.md#validator-assignments # TODO we could cache the validator assignment since it's valid for the entire # epoch since it doesn't change, but that has to be weighed against # the complexity of handling forks correctly - instead, we use an adapted diff --git a/beacon_chain/validator_pool.nim b/beacon_chain/validator_pool.nim index 43ece331c..cd0df2216 100644 --- a/beacon_chain/validator_pool.nim +++ b/beacon_chain/validator_pool.nim @@ -24,7 +24,7 @@ func getValidator*(pool: ValidatorPool, validatorKey: ValidatorPubKey): AttachedValidator = pool.validators.getOrDefault(validatorKey) -# TODO: Honest validator - https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md +# TODO: Honest validator - https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/validator.md proc signBlockProposal*(v: AttachedValidator, fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot, blockRoot: Eth2Digest): Future[ValidatorSig] {.async.} =