1
1
# beacon_chain
2
- # Copyright (c) 2018-2021 Status Research & Development GmbH
2
+ # Copyright (c) 2018-2022 Status Research & Development GmbH
3
3
# Licensed and distributed under either of
4
4
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
5
5
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
13
13
json_serialization/ std/ sets,
14
14
chronicles,
15
15
../ extras,
16
- ./ datatypes/ [phase0, altair, merge ],
16
+ ./ datatypes/ [phase0, altair, bellatrix ],
17
17
" ." / [eth2_merkleization, forks, signatures, validator]
18
18
19
19
export extras, forks, validator
@@ -153,7 +153,7 @@ proc slash_validator*(
153
153
elif state is altair.BeaconState :
154
154
decrease_balance (state, slashed_index,
155
155
validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR )
156
- elif state is merge .BeaconState :
156
+ elif state is bellatrix .BeaconState :
157
157
decrease_balance (state, slashed_index,
158
158
validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_MERGE )
159
159
else :
@@ -174,7 +174,7 @@ proc slash_validator*(
174
174
proposer_reward =
175
175
when state is phase0.BeaconState :
176
176
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 :
178
178
whistleblower_reward * PROPOSER_WEIGHT div WEIGHT_DENOMINATOR
179
179
else :
180
180
raiseAssert " invalid BeaconState type"
@@ -315,15 +315,15 @@ func get_initial_beacon_block*(state: altair.HashedBeaconState):
315
315
message: message, root: hash_tree_root (message))
316
316
317
317
# 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 =
320
320
# The genesis block is implicitly trusted
321
- let message = merge .TrustedBeaconBlock (
321
+ let message = bellatrix .TrustedBeaconBlock (
322
322
slot: state.data.slot,
323
323
state_root: state.root)
324
324
# parent_root, randao_reveal, eth1_data, signature, and body automatically
325
325
# initialized to default values.
326
- merge .TrustedSignedBeaconBlock (
326
+ bellatrix .TrustedSignedBeaconBlock (
327
327
message: message, root: hash_tree_root (message))
328
328
329
329
func get_initial_beacon_block * (state: ForkedHashedBeaconState ):
@@ -525,7 +525,7 @@ func check_attestation_index(
525
525
ok ()
526
526
527
527
# 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 ,
529
529
data: AttestationData ,
530
530
inclusion_delay: uint64 ): seq [int ] =
531
531
# # Return the flag indices that are satisfied by an attestation.
@@ -580,7 +580,7 @@ func get_base_reward_per_increment*(
580
580
581
581
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#get_base_reward
582
582
func get_base_reward (
583
- state: altair.BeaconState | merge .BeaconState , index: ValidatorIndex ,
583
+ state: altair.BeaconState | bellatrix .BeaconState , index: ValidatorIndex ,
584
584
base_reward_per_increment: Gwei ): Gwei =
585
585
# # Return the base reward for the validator defined by ``index`` with respect
586
586
# # to the current ``state``.
@@ -689,7 +689,7 @@ proc process_attestation*(
689
689
addPendingAttestation (state.current_epoch_attestations)
690
690
else :
691
691
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 :
693
693
doAssert base_reward_per_increment > 0 .Gwei
694
694
if attestation.data.target.epoch == get_current_epoch (state):
695
695
updateParticipationFlags (state.current_epoch_participation)
@@ -701,7 +701,7 @@ proc process_attestation*(
701
701
ok ()
702
702
703
703
# 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 ):
705
705
array [SYNC_COMMITTEE_SIZE , ValidatorPubKey ] =
706
706
# # Return the sequence of sync committee indices (which may include
707
707
# # 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)
737
737
res
738
738
739
739
# 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 ):
741
741
SyncCommittee =
742
742
# # Return the *next* sync committee for a given ``state``.
743
743
var res: SyncCommittee
@@ -842,9 +842,9 @@ proc upgrade_to_altair*(cfg: RuntimeConfig, pre: phase0.BeaconState): ref altair
842
842
843
843
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/fork.md#upgrading-the-state
844
844
func upgrade_to_merge * (cfg: RuntimeConfig , pre: altair.BeaconState ):
845
- ref merge .BeaconState =
845
+ ref bellatrix .BeaconState =
846
846
let epoch = get_current_epoch (pre)
847
- (ref merge .BeaconState )(
847
+ (ref bellatrix .BeaconState )(
848
848
# Versioning
849
849
genesis_time: pre.genesis_time,
850
850
genesis_validators_root: pre.genesis_validators_root,
@@ -926,7 +926,7 @@ func latest_block_root*(state: ForkyHashedBeaconState): Eth2Digest =
926
926
latest_block_root (state.data, state.root)
927
927
928
928
func get_sync_committee_cache * (
929
- state: altair.BeaconState | merge .BeaconState , cache: var StateCache ):
929
+ state: altair.BeaconState | bellatrix .BeaconState , cache: var StateCache ):
930
930
SyncCommitteeCache =
931
931
let period = state.slot.sync_committee_period ()
932
932
0 commit comments