Skip to content

Commit 8242e57

Browse files
authored
initial migration from spec/datatypes/{merge => bellatrix} (#3249)
1 parent 2a12d1c commit 8242e57

15 files changed

+511
-509
lines changed

beacon_chain/spec/beaconstate.nim

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# beacon_chain
2-
# Copyright (c) 2018-2021 Status Research & Development GmbH
2+
# Copyright (c) 2018-2022 Status Research & Development GmbH
33
# Licensed and distributed under either of
44
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -13,7 +13,7 @@ import
1313
json_serialization/std/sets,
1414
chronicles,
1515
../extras,
16-
./datatypes/[phase0, altair, merge],
16+
./datatypes/[phase0, altair, bellatrix],
1717
"."/[eth2_merkleization, forks, signatures, validator]
1818

1919
export extras, forks, validator
@@ -153,7 +153,7 @@ proc slash_validator*(
153153
elif state is altair.BeaconState:
154154
decrease_balance(state, slashed_index,
155155
validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR)
156-
elif state is merge.BeaconState:
156+
elif state is bellatrix.BeaconState:
157157
decrease_balance(state, slashed_index,
158158
validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_MERGE)
159159
else:
@@ -174,7 +174,7 @@ proc slash_validator*(
174174
proposer_reward =
175175
when state is phase0.BeaconState:
176176
whistleblower_reward div PROPOSER_REWARD_QUOTIENT
177-
elif state is altair.BeaconState or state is merge.BeaconState:
177+
elif state is altair.BeaconState or state is bellatrix.BeaconState:
178178
whistleblower_reward * PROPOSER_WEIGHT div WEIGHT_DENOMINATOR
179179
else:
180180
raiseAssert "invalid BeaconState type"
@@ -315,15 +315,15 @@ func get_initial_beacon_block*(state: altair.HashedBeaconState):
315315
message: message, root: hash_tree_root(message))
316316

317317
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#testing
318-
func get_initial_beacon_block*(state: merge.HashedBeaconState):
319-
merge.TrustedSignedBeaconBlock =
318+
func get_initial_beacon_block*(state: bellatrix.HashedBeaconState):
319+
bellatrix.TrustedSignedBeaconBlock =
320320
# The genesis block is implicitly trusted
321-
let message = merge.TrustedBeaconBlock(
321+
let message = bellatrix.TrustedBeaconBlock(
322322
slot: state.data.slot,
323323
state_root: state.root)
324324
# parent_root, randao_reveal, eth1_data, signature, and body automatically
325325
# initialized to default values.
326-
merge.TrustedSignedBeaconBlock(
326+
bellatrix.TrustedSignedBeaconBlock(
327327
message: message, root: hash_tree_root(message))
328328

329329
func get_initial_beacon_block*(state: ForkedHashedBeaconState):
@@ -525,7 +525,7 @@ func check_attestation_index(
525525
ok()
526526

527527
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#get_attestation_participation_flag_indices
528-
func get_attestation_participation_flag_indices(state: altair.BeaconState | merge.BeaconState,
528+
func get_attestation_participation_flag_indices(state: altair.BeaconState | bellatrix.BeaconState,
529529
data: AttestationData,
530530
inclusion_delay: uint64): seq[int] =
531531
## Return the flag indices that are satisfied by an attestation.
@@ -580,7 +580,7 @@ func get_base_reward_per_increment*(
580580

581581
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#get_base_reward
582582
func get_base_reward(
583-
state: altair.BeaconState | merge.BeaconState, index: ValidatorIndex,
583+
state: altair.BeaconState | bellatrix.BeaconState, index: ValidatorIndex,
584584
base_reward_per_increment: Gwei): Gwei =
585585
## Return the base reward for the validator defined by ``index`` with respect
586586
## to the current ``state``.
@@ -689,7 +689,7 @@ proc process_attestation*(
689689
addPendingAttestation(state.current_epoch_attestations)
690690
else:
691691
addPendingAttestation(state.previous_epoch_attestations)
692-
elif state is altair.BeaconState or state is merge.BeaconState:
692+
elif state is altair.BeaconState or state is bellatrix.BeaconState:
693693
doAssert base_reward_per_increment > 0.Gwei
694694
if attestation.data.target.epoch == get_current_epoch(state):
695695
updateParticipationFlags(state.current_epoch_participation)
@@ -701,7 +701,7 @@ proc process_attestation*(
701701
ok()
702702

703703
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#get_next_sync_committee_indices
704-
func get_next_sync_committee_keys(state: altair.BeaconState | merge.BeaconState):
704+
func get_next_sync_committee_keys(state: altair.BeaconState | bellatrix.BeaconState):
705705
array[SYNC_COMMITTEE_SIZE, ValidatorPubKey] =
706706
## Return the sequence of sync committee indices (which may include
707707
## duplicate indices) for the next sync committee, given a ``state`` at a
@@ -737,7 +737,7 @@ func get_next_sync_committee_keys(state: altair.BeaconState | merge.BeaconState)
737737
res
738738

739739
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#get_next_sync_committee
740-
proc get_next_sync_committee*(state: altair.BeaconState | merge.BeaconState):
740+
proc get_next_sync_committee*(state: altair.BeaconState | bellatrix.BeaconState):
741741
SyncCommittee =
742742
## Return the *next* sync committee for a given ``state``.
743743
var res: SyncCommittee
@@ -842,9 +842,9 @@ proc upgrade_to_altair*(cfg: RuntimeConfig, pre: phase0.BeaconState): ref altair
842842

843843
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/fork.md#upgrading-the-state
844844
func upgrade_to_merge*(cfg: RuntimeConfig, pre: altair.BeaconState):
845-
ref merge.BeaconState =
845+
ref bellatrix.BeaconState =
846846
let epoch = get_current_epoch(pre)
847-
(ref merge.BeaconState)(
847+
(ref bellatrix.BeaconState)(
848848
# Versioning
849849
genesis_time: pre.genesis_time,
850850
genesis_validators_root: pre.genesis_validators_root,
@@ -926,7 +926,7 @@ func latest_block_root*(state: ForkyHashedBeaconState): Eth2Digest =
926926
latest_block_root(state.data, state.root)
927927

928928
func get_sync_committee_cache*(
929-
state: altair.BeaconState | merge.BeaconState, cache: var StateCache):
929+
state: altair.BeaconState | bellatrix.BeaconState, cache: var StateCache):
930930
SyncCommitteeCache =
931931
let period = state.slot.sync_committee_period()
932932

0 commit comments

Comments
 (0)