mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-21 19:20:38 +00:00
Update go to 1.19.3 (#11630)
* Update go to 1.19.3 * Update other items to 1.19 * Update golangci-lint to latest release * Run gofmt -s with go1.19 * Huge gofmt changes Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
parent
07d0a00f88
commit
4b033f4cc7
12
.github/workflows/go.yml
vendored
12
.github/workflows/go.yml
vendored
@ -26,10 +26,10 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Go 1.18
|
||||
- name: Set up Go 1.19
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
go-version: 1.19
|
||||
- name: Run Gosec Security Scanner
|
||||
run: | # https://github.com/securego/gosec/issues/469
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
@ -43,16 +43,16 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Go 1.18
|
||||
- name: Set up Go 1.19
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
go-version: 1.19
|
||||
id: go
|
||||
|
||||
- name: Golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.47.2
|
||||
version: v1.50.1
|
||||
args: --config=.golangci.yml --out-${NO_FUTURE}format colored-line-number
|
||||
|
||||
build:
|
||||
@ -62,7 +62,7 @@ jobs:
|
||||
- name: Set up Go 1.x
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18
|
||||
go-version: 1.19
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
|
@ -6,7 +6,7 @@ run:
|
||||
- proto
|
||||
- tools/analyzers
|
||||
timeout: 10m
|
||||
go: '1.18'
|
||||
go: '1.19'
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
|
@ -176,7 +176,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe
|
||||
go_rules_dependencies()
|
||||
|
||||
go_register_toolchains(
|
||||
go_version = "1.18.5",
|
||||
go_version = "1.19.3",
|
||||
nogo = "@//:nogo",
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
Package beacon provides a client for interacting with the standard Eth Beacon Node API.
|
||||
Interactive swagger documentation for the API is available here: https://ethereum.github.io/beacon-APIs/
|
||||
|
||||
*/
|
||||
package beacon
|
||||
|
@ -3,7 +3,9 @@ Copyright 2017 Albert Tedja
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -3,7 +3,9 @@ Copyright 2017 Albert Tedja
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
// validateMergeBlock validates terminal block hash in the event of manual overrides before checking for total difficulty.
|
||||
//
|
||||
// def validate_merge_block(block: BeaconBlock) -> None:
|
||||
//
|
||||
// if TERMINAL_BLOCK_HASH != Hash32():
|
||||
// # If `TERMINAL_BLOCK_HASH` is used as an override, the activation epoch must be reached.
|
||||
// assert compute_epoch_at_slot(block.slot) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
|
||||
@ -105,6 +106,7 @@ func (s *Service) getBlkParentHashAndTD(ctx context.Context, blkHash []byte) ([]
|
||||
// validateTerminalBlockHash validates if the merge block is a valid terminal PoW block.
|
||||
// spec code:
|
||||
// if TERMINAL_BLOCK_HASH != Hash32():
|
||||
//
|
||||
// # If `TERMINAL_BLOCK_HASH` is used as an override, the activation epoch must be reached.
|
||||
// assert compute_epoch_at_slot(block.slot) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
|
||||
// assert block.body.execution_payload.parent_hash == TERMINAL_BLOCK_HASH
|
||||
@ -125,6 +127,7 @@ func validateTerminalBlockHash(blkSlot types.Slot, payload interfaces.ExecutionD
|
||||
// validateTerminalBlockDifficulties validates terminal pow block by comparing own total difficulty with parent's total difficulty.
|
||||
//
|
||||
// def is_valid_terminal_pow_block(block: PowBlock, parent: PowBlock) -> bool:
|
||||
//
|
||||
// is_total_difficulty_reached = block.total_difficulty >= TERMINAL_TOTAL_DIFFICULTY
|
||||
// is_parent_total_difficulty_valid = parent.total_difficulty < TERMINAL_TOTAL_DIFFICULTY
|
||||
// return is_total_difficulty_reached and is_parent_total_difficulty_valid
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
// The delay is handled by the caller in `processAttestations`.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def on_attestation(store: Store, attestation: Attestation) -> None:
|
||||
// """
|
||||
// Run ``on_attestation`` upon receiving a new ``attestation`` from either within a block or directly on the wire.
|
||||
|
@ -45,6 +45,7 @@ var initialSyncBlockCacheSize = uint64(2 * params.BeaconConfig().SlotsPerEpoch)
|
||||
// computation in this method and methods it calls into.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
|
||||
// block = signed_block.message
|
||||
// # Parent block must be known
|
||||
|
@ -185,6 +185,7 @@ func (s *Service) updateFinalized(ctx context.Context, cp *ethpb.Checkpoint) err
|
||||
// ancestor returns the block root of an ancestry block from the input block root.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_ancestor(store: Store, root: Root, slot: Slot) -> Root:
|
||||
// block = store.blocks[root]
|
||||
// if block.slot > slot:
|
||||
|
@ -446,8 +446,11 @@ func TestFillForkChoiceMissingBlocks_FinalizedSibling(t *testing.T) {
|
||||
}
|
||||
|
||||
// blockTree1 constructs the following tree:
|
||||
//
|
||||
// /- B1
|
||||
//
|
||||
// B0 /- B5 - B7
|
||||
//
|
||||
// \- B3 - B4 - B6 - B8
|
||||
func blockTree1(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][]byte, error) {
|
||||
genesisRoot = bytesutil.PadTo(genesisRoot, 32)
|
||||
|
@ -82,6 +82,7 @@ func ProcessAttestationNoVerifySignature(
|
||||
// the proposer in state.
|
||||
//
|
||||
// Spec code:
|
||||
//
|
||||
// # Update epoch participation flags
|
||||
// if data.target.epoch == get_current_epoch(state):
|
||||
// epoch_participation = state.current_epoch_participation
|
||||
@ -157,6 +158,7 @@ func AddValidatorFlag(flag, flagPosition uint8) (uint8, error) {
|
||||
// EpochParticipation sets and returns the proposer reward numerator and epoch participation.
|
||||
//
|
||||
// Spec code:
|
||||
//
|
||||
// proposer_reward_numerator = 0
|
||||
// for index in get_attesting_indices(state, data, attestation.aggregation_bits):
|
||||
// for flag_index, weight in enumerate(PARTICIPATION_FLAG_WEIGHTS):
|
||||
@ -218,6 +220,7 @@ func EpochParticipation(beaconState state.BeaconState, indices []uint64, epochPa
|
||||
// RewardProposer rewards proposer by increasing proposer's balance with input reward numerator and calculated reward denominator.
|
||||
//
|
||||
// Spec code:
|
||||
//
|
||||
// proposer_reward_denominator = (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT) * WEIGHT_DENOMINATOR // PROPOSER_WEIGHT
|
||||
// proposer_reward = Gwei(proposer_reward_numerator // proposer_reward_denominator)
|
||||
// increase_balance(state, get_beacon_proposer_index(state), proposer_reward)
|
||||
@ -238,6 +241,7 @@ func RewardProposer(ctx context.Context, beaconState state.BeaconState, proposer
|
||||
//
|
||||
// Spec code:
|
||||
// def get_attestation_participation_flag_indices(state: BeaconState,
|
||||
//
|
||||
// data: AttestationData,
|
||||
// inclusion_delay: uint64) -> Sequence[int]:
|
||||
// """
|
||||
@ -304,6 +308,7 @@ func AttestationParticipationFlagIndices(beaconState state.BeaconState, data *et
|
||||
// MatchingStatus returns the matching statues for attestation data's source target and head.
|
||||
//
|
||||
// Spec code:
|
||||
//
|
||||
// is_matching_source = data.source == justified_checkpoint
|
||||
// is_matching_target = is_matching_source and data.target.root == get_block_root(state, data.target.epoch)
|
||||
// is_matching_head = is_matching_target and data.beacon_block_root == get_block_root_at_slot(state, data.slot)
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
//
|
||||
// Spec code:
|
||||
// def process_sync_aggregate(state: BeaconState, sync_aggregate: SyncAggregate) -> None:
|
||||
//
|
||||
// # Verify sync committee aggregate signature signing over the previous slot block root
|
||||
// committee_pubkeys = state.current_sync_committee.pubkeys
|
||||
// participant_pubkeys = [pubkey for pubkey, bit in zip(committee_pubkeys, sync_aggregate.sync_committee_bits) if bit]
|
||||
|
@ -68,6 +68,7 @@ func InitializePrecomputeValidators(ctx context.Context, beaconState state.Beaco
|
||||
// For fully inactive validators and perfect active validators, the effect is the same as before Altair.
|
||||
// For a validator is inactive and the chain fails to finalize, the inactivity score increases by a fixed number, the total loss after N epochs is proportional to N**2/2.
|
||||
// For imperfectly active validators. The inactivity score's behavior is specified by this function:
|
||||
//
|
||||
// If a validator fails to submit an attestation with the correct target, their inactivity score goes up by 4.
|
||||
// If they successfully submit an attestation with the correct source and target, their inactivity score drops by 1
|
||||
// If the chain has recently finalized, each validator's score drops by 16.
|
||||
@ -132,6 +133,7 @@ func ProcessInactivityScores(
|
||||
// it also tracks and updates epoch attesting balances.
|
||||
// Spec code:
|
||||
// if epoch == get_current_epoch(state):
|
||||
//
|
||||
// epoch_participation = state.current_epoch_participation
|
||||
// else:
|
||||
// epoch_participation = state.previous_epoch_participation
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
//
|
||||
// Spec code:
|
||||
// def process_sync_committee_updates(state: BeaconState) -> None:
|
||||
//
|
||||
// next_epoch = get_current_epoch(state) + Epoch(1)
|
||||
// if next_epoch % EPOCHS_PER_SYNC_COMMITTEE_PERIOD == 0:
|
||||
// state.current_sync_committee = state.next_sync_committee
|
||||
@ -46,6 +47,7 @@ func ProcessSyncCommitteeUpdates(ctx context.Context, beaconState state.BeaconSt
|
||||
//
|
||||
// Spec code:
|
||||
// def process_participation_flag_updates(state: BeaconState) -> None:
|
||||
//
|
||||
// state.previous_epoch_participation = state.current_epoch_participation
|
||||
// state.current_epoch_participation = [ParticipationFlags(0b0000_0000) for _ in range(len(state.validators))]
|
||||
func ProcessParticipationFlagUpdates(beaconState state.BeaconState) (state.BeaconState, error) {
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
// individual validator's base reward.
|
||||
//
|
||||
// Spec code:
|
||||
//
|
||||
// def get_base_reward(state: BeaconState, index: ValidatorIndex) -> Gwei:
|
||||
// """
|
||||
// Return the base reward for the validator defined by ``index`` with respect to the current ``state``.
|
||||
@ -50,6 +51,7 @@ func BaseRewardWithTotalBalance(s state.ReadOnlyBeaconState, index types.Validat
|
||||
//
|
||||
// Spec code:
|
||||
// def get_base_reward_per_increment(state: BeaconState) -> Gwei:
|
||||
//
|
||||
// return Gwei(EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR // integer_squareroot(get_total_active_balance(state)))
|
||||
func BaseRewardPerIncrement(activeBalance uint64) (uint64, error) {
|
||||
if activeBalance == 0 {
|
||||
|
@ -47,6 +47,7 @@ func ValidateNilSyncContribution(s *ethpb.SignedContributionAndProof) error {
|
||||
//
|
||||
// Spec code:
|
||||
// def get_next_sync_committee(state: BeaconState) -> SyncCommittee:
|
||||
//
|
||||
// """
|
||||
// Return the next sync committee, with possible pubkey duplicates.
|
||||
// """
|
||||
@ -78,6 +79,7 @@ func NextSyncCommittee(ctx context.Context, s state.BeaconState) (*ethpb.SyncCom
|
||||
//
|
||||
// Spec code:
|
||||
// def get_next_sync_committee_indices(state: BeaconState) -> Sequence[ValidatorIndex]:
|
||||
//
|
||||
// """
|
||||
// Return the sync committee indices, with possible duplicates, for the next sync committee.
|
||||
// """
|
||||
@ -144,6 +146,7 @@ func NextSyncCommitteeIndices(ctx context.Context, s state.BeaconState) ([]types
|
||||
// SyncSubCommitteePubkeys returns the pubkeys participating in a sync subcommittee.
|
||||
//
|
||||
// def get_sync_subcommittee_pubkeys(state: BeaconState, subcommittee_index: uint64) -> Sequence[BLSPubkey]:
|
||||
//
|
||||
// # Committees assigned to `slot` sign for `slot - 1`
|
||||
// # This creates the exceptional logic below when transitioning between sync committee periods
|
||||
// next_slot_epoch = compute_epoch_at_slot(Slot(state.slot + 1))
|
||||
@ -172,6 +175,7 @@ func SyncSubCommitteePubkeys(syncCommittee *ethpb.SyncCommittee, subComIdx types
|
||||
// aggregator.
|
||||
//
|
||||
// def is_sync_committee_aggregator(signature: BLSSignature) -> bool:
|
||||
//
|
||||
// modulo = max(1, SYNC_COMMITTEE_SIZE // SYNC_COMMITTEE_SUBNET_COUNT // TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE)
|
||||
// return bytes_to_uint64(hash(signature)[0:8]) % modulo == 0
|
||||
func IsSyncCommitteeAggregator(sig []byte) (bool, error) {
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
//
|
||||
// Spec code:
|
||||
// def process_epoch(state: BeaconState) -> None:
|
||||
//
|
||||
// process_justification_and_finalization(state) # [Modified in Altair]
|
||||
// process_inactivity_updates(state) # [New in Altair]
|
||||
// process_rewards_and_penalties(state) # [Modified in Altair]
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
//
|
||||
// Spec code:
|
||||
// def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
|
||||
//
|
||||
// epoch = phase0.get_current_epoch(pre)
|
||||
// post = BeaconState(
|
||||
// # Versioning
|
||||
@ -126,6 +127,7 @@ func UpgradeToAltair(ctx context.Context, state state.BeaconState) (state.Beacon
|
||||
//
|
||||
// Spec code:
|
||||
// def translate_participation(state: BeaconState, pending_attestations: Sequence[phase0.PendingAttestation]) -> None:
|
||||
//
|
||||
// for attestation in pending_attestations:
|
||||
// data = attestation.data
|
||||
// inclusion_delay = attestation.inclusion_delay
|
||||
|
@ -185,6 +185,7 @@ func VerifyAttestationSignature(ctx context.Context, beaconState state.ReadOnlyB
|
||||
// VerifyIndexedAttestation determines the validity of an indexed attestation.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def is_valid_indexed_attestation(state: BeaconState, indexed_attestation: IndexedAttestation) -> bool:
|
||||
// """
|
||||
// Check if ``indexed_attestation`` is not empty, has sorted and unique indices and has a valid aggregate signature.
|
||||
|
@ -71,6 +71,7 @@ func ActivateValidatorWithEffectiveBalance(beaconState state.BeaconState, deposi
|
||||
// into the beacon chain.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// For each deposit in block.body.deposits:
|
||||
// process_deposit(state, deposit)
|
||||
func ProcessDeposits(
|
||||
@ -120,6 +121,7 @@ func BatchVerifyDepositsSignatures(ctx context.Context, deposits []*ethpb.Deposi
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
// def process_deposit(state: BeaconState, deposit: Deposit) -> None:
|
||||
//
|
||||
// # Verify the Merkle branch
|
||||
// assert is_valid_merkle_branch(
|
||||
// leaf=hash_tree_root(deposit.data),
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
// into the beacon state.
|
||||
//
|
||||
// Official spec definition:
|
||||
//
|
||||
// def process_eth1_data(state: BeaconState, body: BeaconBlockBody) -> None:
|
||||
// state.eth1_data_votes.append(body.eth1_data)
|
||||
// if state.eth1_data_votes.count(body.eth1_data) * 2 > EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH:
|
||||
|
@ -27,6 +27,7 @@ var ValidatorCannotExitYetMsg = "validator has not been active long enough to ex
|
||||
// should exit the state's validator registry.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVoluntaryExit) -> None:
|
||||
// voluntary_exit = signed_voluntary_exit.message
|
||||
// validator = state.validators[voluntary_exit.validator_index]
|
||||
@ -71,6 +72,7 @@ func ProcessVoluntaryExits(
|
||||
// VerifyExitAndSignature implements the spec defined validation for voluntary exits.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVoluntaryExit) -> None:
|
||||
// voluntary_exit = signed_voluntary_exit.message
|
||||
// validator = state.validators[voluntary_exit.validator_index]
|
||||
@ -117,6 +119,7 @@ func VerifyExitAndSignature(
|
||||
// verifyExitConditions implements the spec defined validation for voluntary exits(excluding signatures).
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVoluntaryExit) -> None:
|
||||
// voluntary_exit = signed_voluntary_exit.message
|
||||
// validator = state.validators[voluntary_exit.validator_index]
|
||||
|
@ -73,6 +73,7 @@ func ProcessBlockHeader(
|
||||
// using a unsigned block.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_block_header(state: BeaconState, block: BeaconBlock) -> None:
|
||||
// # Verify that the slots match
|
||||
// assert block.slot == state.slot
|
||||
|
@ -25,6 +25,7 @@ var (
|
||||
//
|
||||
// Spec code:
|
||||
// def is_merge_transition_complete(state: BeaconState) -> bool:
|
||||
//
|
||||
// return state.latest_execution_payload_header != ExecutionPayloadHeader()
|
||||
func IsMergeTransitionComplete(st state.BeaconState) (bool, error) {
|
||||
if st == nil {
|
||||
@ -51,6 +52,7 @@ func IsMergeTransitionComplete(st state.BeaconState) (bool, error) {
|
||||
//
|
||||
// Spec code:
|
||||
// def is_execution_block(block: BeaconBlock) -> bool:
|
||||
//
|
||||
// return block.body.execution_payload != ExecutionPayload()
|
||||
func IsExecutionBlock(body interfaces.BeaconBlockBody) (bool, error) {
|
||||
if body == nil {
|
||||
@ -76,6 +78,7 @@ func IsExecutionBlock(body interfaces.BeaconBlockBody) (bool, error) {
|
||||
//
|
||||
// Spec code:
|
||||
// def is_execution_enabled(state: BeaconState, body: BeaconBlockBody) -> bool:
|
||||
//
|
||||
// return is_merge_block(state, body) or is_merge_complete(state)
|
||||
func IsExecutionEnabled(st state.BeaconState, body interfaces.BeaconBlockBody) (bool, error) {
|
||||
if st == nil || body == nil {
|
||||
@ -116,6 +119,7 @@ func IsPreBellatrixVersion(v int) bool {
|
||||
// These validation steps ONLY apply to post merge.
|
||||
//
|
||||
// Spec code:
|
||||
//
|
||||
// # Verify consistency of the parent hash with respect to the previous execution payload header
|
||||
// if is_merge_complete(state):
|
||||
// assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
||||
@ -141,6 +145,7 @@ func ValidatePayloadWhenMergeCompletes(st state.BeaconState, payload interfaces.
|
||||
// These validation steps apply to both pre merge and post merge.
|
||||
//
|
||||
// Spec code:
|
||||
//
|
||||
// # Verify random
|
||||
// assert payload.random == get_randao_mix(state, get_current_epoch(state))
|
||||
// # Verify timestamp
|
||||
@ -170,6 +175,7 @@ func ValidatePayload(st state.BeaconState, payload interfaces.ExecutionData) err
|
||||
//
|
||||
// Spec code:
|
||||
// def process_execution_payload(state: BeaconState, payload: ExecutionPayload, execution_engine: ExecutionEngine) -> None:
|
||||
//
|
||||
// # Verify consistency of the parent hash with respect to the previous execution payload header
|
||||
// if is_merge_complete(state):
|
||||
// assert payload.parent_hash == state.latest_execution_payload_header.block_hash
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
// in the beacon state's latest randao mixes slice.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_randao(state: BeaconState, body: BeaconBlockBody) -> None:
|
||||
// epoch = get_current_epoch(state)
|
||||
// # Verify RANDAO reveal
|
||||
@ -56,6 +57,7 @@ func ProcessRandao(
|
||||
// in the beacon state's latest randao mixes slice.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// # Mix it in
|
||||
// state.latest_randao_mixes[get_current_epoch(state) % LATEST_RANDAO_MIXES_LENGTH] = (
|
||||
// xor(get_randao_mix(state, get_current_epoch(state)),
|
||||
|
@ -24,6 +24,7 @@ const executionToBLSPadding = 12
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_bls_to_execution_change(state: BeaconState, signed_address_change: SignedBLSToExecutionChange) -> None:
|
||||
//
|
||||
// validator = state.validators[address_change.validator_index]
|
||||
//
|
||||
// assert validator.withdrawal_credentials[:1] == BLS_WITHDRAWAL_PREFIX
|
||||
@ -38,7 +39,6 @@ const executionToBLSPadding = 12
|
||||
// + b'\x00' * 11
|
||||
// + address_change.to_execution_address
|
||||
// )
|
||||
//
|
||||
func ProcessBLSToExecutionChange(st state.BeaconState, signed *ethpb.SignedBLSToExecutionChange) (state.BeaconState, error) {
|
||||
if signed == nil {
|
||||
return st, errNilSignedWithdrawalMessage
|
||||
|
@ -49,6 +49,7 @@ func (s sortableIndices) Less(i, j int) bool {
|
||||
// need to get attesting balance from attestations.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_attesting_balance(state: BeaconState, attestations: Sequence[PendingAttestation]) -> Gwei:
|
||||
// """
|
||||
// Return the combined effective balance of the set of unslashed validators participating in ``attestations``.
|
||||
@ -67,6 +68,7 @@ func AttestingBalance(ctx context.Context, state state.ReadOnlyBeaconState, atts
|
||||
// the amount to rotate is determined churn limit.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_registry_updates(state: BeaconState) -> None:
|
||||
// # Process activation eligibility and ejections
|
||||
// for index, validator in enumerate(state.validators):
|
||||
@ -207,6 +209,7 @@ func ProcessSlashings(state state.BeaconState, slashingMultiplier uint64) (state
|
||||
// ProcessEth1DataReset processes updates to ETH1 data votes during epoch processing.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_eth1_data_reset(state: BeaconState) -> None:
|
||||
// next_epoch = Epoch(get_current_epoch(state) + 1)
|
||||
// # Reset eth1 data votes
|
||||
@ -229,6 +232,7 @@ func ProcessEth1DataReset(state state.BeaconState) (state.BeaconState, error) {
|
||||
// ProcessEffectiveBalanceUpdates processes effective balance updates during epoch processing.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_effective_balance_updates(state: BeaconState) -> None:
|
||||
// # Update effective balances with hysteresis
|
||||
// for index, validator in enumerate(state.validators):
|
||||
@ -285,6 +289,7 @@ func ProcessEffectiveBalanceUpdates(state state.BeaconState) (state.BeaconState,
|
||||
// ProcessSlashingsReset processes the total slashing balances updates during epoch processing.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_slashings_reset(state: BeaconState) -> None:
|
||||
// next_epoch = Epoch(get_current_epoch(state) + 1)
|
||||
// # Reset slashings
|
||||
@ -314,6 +319,7 @@ func ProcessSlashingsReset(state state.BeaconState) (state.BeaconState, error) {
|
||||
// ProcessRandaoMixesReset processes the final updates to RANDAO mix during epoch processing.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_randao_mixes_reset(state: BeaconState) -> None:
|
||||
// current_epoch = get_current_epoch(state)
|
||||
// next_epoch = Epoch(current_epoch + 1)
|
||||
@ -346,6 +352,7 @@ func ProcessRandaoMixesReset(state state.BeaconState) (state.BeaconState, error)
|
||||
// ProcessHistoricalRootsUpdate processes the updates to historical root accumulator during epoch processing.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_historical_roots_update(state: BeaconState) -> None:
|
||||
// # Set historical root accumulator
|
||||
// next_epoch = Epoch(get_current_epoch(state) + 1)
|
||||
@ -378,6 +385,7 @@ func ProcessHistoricalRootsUpdate(state state.BeaconState) (state.BeaconState, e
|
||||
// ProcessParticipationRecordUpdates rotates current/previous epoch attestations during epoch processing.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_participation_record_updates(state: BeaconState) -> None:
|
||||
// # Rotate current/previous epoch attestations
|
||||
// state.previous_epoch_attestations = state.current_epoch_attestations
|
||||
@ -436,6 +444,7 @@ func ProcessFinalUpdates(state state.BeaconState) (state.BeaconState, error) {
|
||||
// it sorts the indices and filters out the slashed ones.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_unslashed_attesting_indices(state: BeaconState,
|
||||
// attestations: Sequence[PendingAttestation]) -> Set[ValidatorIndex]:
|
||||
// output = set() # type: Set[ValidatorIndex]
|
||||
|
@ -42,6 +42,7 @@ func UnrealizedCheckpoints(st state.BeaconState) (uint64, *ethpb.Checkpoint, *et
|
||||
// Note: this is an optimized version by passing in precomputed total and attesting balances.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_justification_and_finalization(state: BeaconState) -> None:
|
||||
// # Initial FFG checkpoint values have a `0x00` stub for `root`.
|
||||
// # Skip FFG updates in the first two epochs to avoid corner cases that might result in modifying this stub.
|
||||
@ -113,6 +114,7 @@ func weighJustificationAndFinalization(state state.BeaconState, newBits bitfield
|
||||
// checkpoints at epoch transition
|
||||
// Spec pseudocode definition:
|
||||
// def weigh_justification_and_finalization(state: BeaconState,
|
||||
//
|
||||
// total_active_balance: Gwei,
|
||||
// previous_epoch_target_balance: Gwei,
|
||||
// current_epoch_target_balance: Gwei) -> None:
|
||||
|
@ -358,6 +358,7 @@ func TestProposerDeltaPrecompute_SlashedCase(t *testing.T) {
|
||||
// individual validator's base reward quotient.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_base_reward(state: BeaconState, index: ValidatorIndex) -> Gwei:
|
||||
// total_balance = get_total_active_balance(state)
|
||||
// effective_balance = state.validators[index].effective_balance
|
||||
|
@ -35,6 +35,7 @@ var (
|
||||
// count.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_committee_count_per_slot(state: BeaconState, epoch: Epoch) -> uint64:
|
||||
// """
|
||||
// Return the number of committees in each slot for the given ``epoch``.
|
||||
@ -61,6 +62,7 @@ func SlotCommitteeCount(activeValidatorCount uint64) uint64 {
|
||||
// becomes expensive, consider using BeaconCommittee below.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_beacon_committee(state: BeaconState, slot: Slot, index: CommitteeIndex) -> Sequence[ValidatorIndex]:
|
||||
// """
|
||||
// Return the beacon committee at ``slot`` for ``index``.
|
||||
@ -101,6 +103,7 @@ func BeaconCommitteeFromState(ctx context.Context, state state.ReadOnlyBeaconSta
|
||||
// from the spec definition. Having them as an argument allows for cheaper computation run time.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_beacon_committee(state: BeaconState, slot: Slot, index: CommitteeIndex) -> Sequence[ValidatorIndex]:
|
||||
// """
|
||||
// Return the beacon committee at ``slot`` for ``index``.
|
||||
@ -381,6 +384,7 @@ func ClearCache() {
|
||||
// validator indices and seed.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_committee(indices: Sequence[ValidatorIndex],
|
||||
// seed: Bytes32,
|
||||
// index: uint64,
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
// It returns an error if the requested block root is not within the slot range.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_block_root_at_slot(state: BeaconState, slot: Slot) -> Root:
|
||||
// """
|
||||
// Return the block root at a recent ``slot``.
|
||||
@ -42,6 +43,7 @@ func StateRootAtSlot(state state.ReadOnlyBeaconState, slot types.Slot) ([]byte,
|
||||
// BlockRoot returns the block root stored in the BeaconState for epoch start slot.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_block_root(state: BeaconState, epoch: Epoch) -> Root:
|
||||
// """
|
||||
// Return the block root at the start of a recent ``epoch``.
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
// Seed returns the randao seed used for shuffling of a given epoch.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_seed(state: BeaconState, epoch: Epoch, domain_type: DomainType) -> Bytes32:
|
||||
// """
|
||||
// Return the seed at ``epoch``.
|
||||
@ -40,6 +41,7 @@ func Seed(state state.ReadOnlyBeaconState, epoch types.Epoch, domain [bls.Domain
|
||||
// of a given slot. It is used to shuffle validators.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_randao_mix(state: BeaconState, epoch: Epoch) -> Bytes32:
|
||||
// """
|
||||
// Return the randao mix at a recent ``epoch``.
|
||||
|
@ -17,6 +17,7 @@ var balanceCache = cache.NewEffectiveBalanceCache()
|
||||
// of input validators.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_total_balance(state: BeaconState, indices: Set[ValidatorIndex]) -> Gwei:
|
||||
// """
|
||||
// Return the combined effective balance of the ``indices``.
|
||||
@ -47,6 +48,7 @@ func TotalBalance(state state.ReadOnlyValidators, indices []types.ValidatorIndex
|
||||
// of active validators.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_total_active_balance(state: BeaconState) -> Gwei:
|
||||
// """
|
||||
// Return the combined effective balance of the active validators.
|
||||
@ -88,6 +90,7 @@ func TotalActiveBalance(s state.ReadOnlyBeaconState) (uint64, error) {
|
||||
// IncreaseBalance increases validator with the given 'index' balance by 'delta' in Gwei.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def increase_balance(state: BeaconState, index: ValidatorIndex, delta: Gwei) -> None:
|
||||
// """
|
||||
// Increase the validator balance at index ``index`` by ``delta``.
|
||||
@ -110,6 +113,7 @@ func IncreaseBalance(state state.BeaconState, idx types.ValidatorIndex, delta ui
|
||||
// the post balance.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def increase_balance(state: BeaconState, index: ValidatorIndex, delta: Gwei) -> None:
|
||||
// """
|
||||
// Increase the validator balance at index ``index`` by ``delta``.
|
||||
@ -122,6 +126,7 @@ func IncreaseBalanceWithVal(currBalance, delta uint64) (uint64, error) {
|
||||
// DecreaseBalance decreases validator with the given 'index' balance by 'delta' in Gwei.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def decrease_balance(state: BeaconState, index: ValidatorIndex, delta: Gwei) -> None:
|
||||
// """
|
||||
// Decrease the validator balance at index ``index`` by ``delta``, with underflow protection.
|
||||
@ -140,6 +145,7 @@ func DecreaseBalance(state state.BeaconState, idx types.ValidatorIndex, delta ui
|
||||
// the post balance.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def decrease_balance(state: BeaconState, index: ValidatorIndex, delta: Gwei) -> None:
|
||||
// """
|
||||
// Decrease the validator balance at index ``index`` by ``delta``, with underflow protection.
|
||||
@ -156,6 +162,7 @@ func DecreaseBalanceWithVal(currBalance, delta uint64) uint64 {
|
||||
//
|
||||
// Spec code:
|
||||
// def is_in_inactivity_leak(state: BeaconState) -> bool:
|
||||
//
|
||||
// return get_finality_delay(state) > MIN_EPOCHS_TO_INACTIVITY_PENALTY
|
||||
func IsInInactivityLeak(prevEpoch, finalizedEpoch types.Epoch) bool {
|
||||
return FinalityDelay(prevEpoch, finalizedEpoch) > params.BeaconConfig().MinEpochsToInactivityPenalty
|
||||
@ -165,6 +172,7 @@ func IsInInactivityLeak(prevEpoch, finalizedEpoch types.Epoch) bool {
|
||||
//
|
||||
// Spec code:
|
||||
// def get_finality_delay(state: BeaconState) -> uint64:
|
||||
//
|
||||
// return get_previous_epoch(state) - state.finalized_checkpoint.epoch
|
||||
func FinalityDelay(prevEpoch, finalizedEpoch types.Epoch) types.Epoch {
|
||||
return prevEpoch - finalizedEpoch
|
||||
|
@ -31,7 +31,7 @@ func SplitIndices(l []uint64, n uint64) [][]uint64 {
|
||||
return divided
|
||||
}
|
||||
|
||||
// ShuffledIndex returns `p(index)` in a pseudorandom permutation `p` of `0...list_size - 1` with ``seed`` as entropy.
|
||||
// ShuffledIndex returns `p(index)` in a pseudorandom permutation `p` of `0...list_size - 1` with “seed“ as entropy.
|
||||
// We utilize 'swap or not' shuffling in this implementation; we are allocating the memory with the seed that stays
|
||||
// constant between iterations instead of reallocating it each iteration as in the spec. This implementation is based
|
||||
// on the original implementation from protolambda, https://github.com/protolambda/eth2-shuffle
|
||||
@ -47,6 +47,7 @@ func UnShuffledIndex(index types.ValidatorIndex, indexCount uint64, seed [32]byt
|
||||
|
||||
// ComputeShuffledIndex returns the shuffled validator index corresponding to seed and index count.
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_shuffled_index(index: uint64, index_count: uint64, seed: Bytes32) -> uint64:
|
||||
// """
|
||||
// Return the shuffled index corresponding to ``seed`` (and ``index_count``).
|
||||
@ -135,10 +136,11 @@ func ComputeShuffledIndex(index types.ValidatorIndex, indexCount uint64, seed [3
|
||||
return index, nil
|
||||
}
|
||||
|
||||
// ShuffleList returns list of shuffled indexes in a pseudorandom permutation `p` of `0...list_size - 1` with ``seed`` as entropy.
|
||||
// ShuffleList returns list of shuffled indexes in a pseudorandom permutation `p` of `0...list_size - 1` with “seed“ as entropy.
|
||||
// We utilize 'swap or not' shuffling in this implementation; we are allocating the memory with the seed that stays
|
||||
// constant between iterations instead of reallocating it each iteration as in the spec. This implementation is based
|
||||
// on the original implementation from protolambda, https://github.com/protolambda/eth2-shuffle
|
||||
//
|
||||
// improvements:
|
||||
// - seed is always the first 32 bytes of the hash input, we just copy it into the buffer one time.
|
||||
// - add round byte to seed and hash that part of the buffer.
|
||||
|
@ -28,6 +28,7 @@ var CommitteeCacheInProgressHit = promauto.NewCounter(prometheus.CounterOpts{
|
||||
// is active or not.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def is_active_validator(validator: Validator, epoch: Epoch) -> bool:
|
||||
// """
|
||||
// Check if ``validator`` is active.
|
||||
@ -50,6 +51,7 @@ func checkValidatorActiveStatus(activationEpoch, exitEpoch, epoch types.Epoch) b
|
||||
// is slashable or not.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def is_slashable_validator(validator: Validator, epoch: Epoch) -> bool:
|
||||
// """
|
||||
// Check if ``validator`` is slashable.
|
||||
@ -78,6 +80,7 @@ func checkValidatorSlashable(activationEpoch, withdrawableEpoch types.Epoch, sla
|
||||
// need the active validator indices for some specific reason.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_active_validator_indices(state: BeaconState, epoch: Epoch) -> Sequence[ValidatorIndex]:
|
||||
// """
|
||||
// Return the sequence of active validator indices at ``epoch``.
|
||||
@ -186,6 +189,7 @@ func ActiveValidatorCount(ctx context.Context, s state.ReadOnlyBeaconState, epoc
|
||||
// the validator is eligible for activation and exit.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_activation_exit_epoch(epoch: Epoch) -> Epoch:
|
||||
// """
|
||||
// Return the epoch during which validator activations and exits initiated in ``epoch`` take effect.
|
||||
@ -199,6 +203,7 @@ func ActivationExitEpoch(epoch types.Epoch) types.Epoch {
|
||||
// enter and exit validator pool for an epoch.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_validator_churn_limit(state: BeaconState) -> uint64:
|
||||
// """
|
||||
// Return the validator churn limit for the current epoch.
|
||||
@ -216,6 +221,7 @@ func ValidatorChurnLimit(activeValidatorCount uint64) (uint64, error) {
|
||||
// BeaconProposerIndex returns proposer index of a current slot.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_beacon_proposer_index(state: BeaconState) -> ValidatorIndex:
|
||||
// """
|
||||
// Return the beacon proposer index at the current slot.
|
||||
@ -274,6 +280,7 @@ func BeaconProposerIndex(ctx context.Context, state state.ReadOnlyBeaconState) (
|
||||
// ComputeProposerIndex returns the index sampled by effective balance, which is used to calculate proposer.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_proposer_index(state: BeaconState, indices: Sequence[ValidatorIndex], seed: Bytes32) -> ValidatorIndex:
|
||||
// """
|
||||
// Return from ``indices`` a random index sampled by effective balance.
|
||||
@ -324,6 +331,7 @@ func ComputeProposerIndex(bState state.ReadOnlyValidators, activeIndices []types
|
||||
// be placed into the activation queue.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def is_eligible_for_activation_queue(validator: Validator) -> bool:
|
||||
// """
|
||||
// Check if ``validator`` is eligible to be placed into the activation queue.
|
||||
@ -351,6 +359,7 @@ func isEligibileForActivationQueue(activationEligibilityEpoch types.Epoch, effec
|
||||
// IsEligibleForActivation checks if the validator is eligible for activation.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def is_eligible_for_activation(state: BeaconState, validator: Validator) -> bool:
|
||||
// """
|
||||
// Check if ``validator`` is eligible for activation.
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
// https://github.com/ethereum/consensus-specs/blob/master/specs/phase0/weak-subjectivity.md#calculating-the-weak-subjectivity-period
|
||||
//
|
||||
// def compute_weak_subjectivity_period(state: BeaconState) -> uint64:
|
||||
//
|
||||
// """
|
||||
// Returns the weak subjectivity period for the current ``state``.
|
||||
// This computation takes into account the effect of:
|
||||
@ -114,6 +115,7 @@ func ComputeWeakSubjectivityPeriod(ctx context.Context, st state.ReadOnlyBeaconS
|
||||
// https://github.com/ethereum/consensus-specs/blob/master/specs/phase0/weak-subjectivity.md#checking-for-stale-weak-subjectivity-checkpoint
|
||||
//
|
||||
// def is_within_weak_subjectivity_period(store: Store, ws_state: BeaconState, ws_checkpoint: Checkpoint) -> bool:
|
||||
//
|
||||
// # Clients may choose to validate the input state against the input Weak Subjectivity Checkpoint
|
||||
// assert ws_state.latest_block_header.state_root == ws_checkpoint.root
|
||||
// assert compute_epoch_at_slot(ws_state.slot) == ws_checkpoint.epoch
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
// Domain returns the domain version for BLS private key to sign and verify.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_domain(state: BeaconState, domain_type: DomainType, epoch: Epoch=None) -> Domain:
|
||||
// """
|
||||
// Return the signature domain (fork version concatenated with domain type) of a message.
|
||||
|
@ -37,6 +37,7 @@ func ComputeDomainAndSign(st state.ReadOnlyBeaconState, epoch types.Epoch, obj f
|
||||
// ComputeSigningRoot computes the root of the object by calculating the hash tree root of the signing data with the given domain.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_signing_root(ssz_object: SSZObject, domain: Domain) -> Root:
|
||||
// """
|
||||
// Return the signing root for the corresponding signing data.
|
||||
@ -160,6 +161,7 @@ func BlockSignatureBatch(pub, signature, domain []byte, rootFunc func() ([32]byt
|
||||
// array as the fork version.
|
||||
//
|
||||
// def compute_domain(domain_type: DomainType, fork_version: Version=None, genesis_validators_root: Root=None) -> Domain:
|
||||
//
|
||||
// """
|
||||
// Return the domain for the ``domain_type`` and ``fork_version``.
|
||||
// """
|
||||
@ -195,10 +197,11 @@ func domain(domainType [DomainByteLength]byte, forkDataRoot []byte) []byte {
|
||||
return b
|
||||
}
|
||||
|
||||
// this returns the 32byte fork data root for the ``current_version`` and ``genesis_validators_root``.
|
||||
// this returns the 32byte fork data root for the “current_version“ and “genesis_validators_root“.
|
||||
// This is used primarily in signature domains to avoid collisions across forks/chains.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_fork_data_root(current_version: Version, genesis_validators_root: Root) -> Root:
|
||||
// """
|
||||
// Return the 32-byte fork data root for the ``current_version`` and ``genesis_validators_root``.
|
||||
@ -222,6 +225,7 @@ func computeForkDataRoot(version, root []byte) ([32]byte, error) {
|
||||
// ComputeForkDigest returns the fork for the current version and genesis validators root
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_fork_digest(current_version: Version, genesis_validators_root: Root) -> ForkDigest:
|
||||
// """
|
||||
// Return the 4-byte fork digest for the ``current_version`` and ``genesis_validators_root``.
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
// the slot number stored in beacon state.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_current_epoch(state: BeaconState) -> Epoch:
|
||||
// """
|
||||
// Return the current epoch.
|
||||
@ -26,6 +27,7 @@ func CurrentEpoch(state state.ReadOnlyBeaconState) types.Epoch {
|
||||
// underflow condition.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def get_previous_epoch(state: BeaconState) -> Epoch:
|
||||
// """`
|
||||
// Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
||||
@ -83,6 +85,7 @@ func CanUpgradeToCapella(slot types.Slot) bool {
|
||||
// The epoch can be processed at the end of the last slot of every epoch.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// If (state.slot + 1) % SLOTS_PER_EPOCH == 0:
|
||||
func CanProcessEpoch(state state.ReadOnlyBeaconState) bool {
|
||||
return (state.Slot()+1)%params.BeaconConfig().SlotsPerEpoch == 0
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
// full deposits were made to the deposit contract and the ChainStart log gets emitted.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def initialize_beacon_state_from_eth1(eth1_block_hash: Bytes32,
|
||||
// eth1_timestamp: uint64,
|
||||
// deposits: Sequence[Deposit]) -> BeaconState:
|
||||
@ -52,6 +53,7 @@ import (
|
||||
// state.genesis_validators_root = hash_tree_root(state.validators)
|
||||
//
|
||||
// return state
|
||||
//
|
||||
// This method differs from the spec so as to process deposits beforehand instead of the end of the function.
|
||||
func GenesisBeaconState(ctx context.Context, deposits []*ethpb.Deposit, genesisTime uint64, eth1Data *ethpb.Eth1Data) (state.BeaconState, error) {
|
||||
st, err := EmptyGenesisState()
|
||||
@ -211,12 +213,14 @@ func EmptyGenesisState() (state.BeaconState, error) {
|
||||
// if the minimum genesis time arrived already.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def is_valid_genesis_state(state: BeaconState) -> bool:
|
||||
// if state.genesis_time < MIN_GENESIS_TIME:
|
||||
// return False
|
||||
// if len(get_active_validator_indices(state, GENESIS_EPOCH)) < MIN_GENESIS_ACTIVE_VALIDATOR_COUNT:
|
||||
// return False
|
||||
// return True
|
||||
//
|
||||
// This method has been modified from the spec to allow whole states not to be saved
|
||||
// but instead only cache the relevant information.
|
||||
func IsValidGenesisState(chainStartDepositCount, currentTime uint64) bool {
|
||||
|
@ -33,6 +33,7 @@ import (
|
||||
// See: ExecuteStateTransitionNoVerifyAnySig
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def state_transition(state: BeaconState, signed_block: SignedBeaconBlock, validate_result: bool=True) -> None:
|
||||
// block = signed_block.message
|
||||
// # Process slots (including those with no blocks) since block
|
||||
@ -177,6 +178,7 @@ func ProcessSlotsIfPossible(ctx context.Context, state state.BeaconState, target
|
||||
// ProcessSlots process through skip slots and apply epoch transition when it's needed
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_slots(state: BeaconState, slot: Slot) -> None:
|
||||
// assert state.slot < slot
|
||||
// while state.slot < slot:
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
// This method also modifies the passed in state.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def state_transition(state: BeaconState, signed_block: SignedBeaconBlock, validate_result: bool=True) -> None:
|
||||
// block = signed_block.message
|
||||
// # Process slots (including those with no blocks) since block
|
||||
@ -94,6 +95,7 @@ func ExecuteStateTransitionNoVerifyAnySig(
|
||||
// This is used for proposer to compute state root before proposing a new block, and this does not modify state.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def state_transition(state: BeaconState, signed_block: SignedBeaconBlock, validate_result: bool=True) -> None:
|
||||
// block = signed_block.message
|
||||
// # Process slots (including those with no blocks) since block
|
||||
@ -260,6 +262,7 @@ func ProcessOperationsNoVerifyAttsSigs(
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
// def process_block(state: BeaconState, block: BeaconBlock) -> None:
|
||||
//
|
||||
// process_block_header(state, block)
|
||||
// if is_execution_enabled(state, block.body):
|
||||
// process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [New in Bellatrix]
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
// validator with correct voluntary exit parameters.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def initiate_validator_exit(state: BeaconState, index: ValidatorIndex) -> None:
|
||||
// """
|
||||
// Initiate the exit of the validator with index ``index``.
|
||||
@ -114,6 +115,7 @@ func InitiateValidatorExit(ctx context.Context, s state.BeaconState, idx types.V
|
||||
// the whistleblower's balance.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def slash_validator(state: BeaconState,
|
||||
// slashed_index: ValidatorIndex,
|
||||
// whistleblower_index: ValidatorIndex=None) -> None:
|
||||
|
@ -76,7 +76,9 @@ func TestStore_IsFinalizedBlockGenesis(t *testing.T) {
|
||||
// Example:
|
||||
// 0 1 2 3 4 5 6 slot
|
||||
// a <- b <-- d <- e <- f <- g roots
|
||||
//
|
||||
// ^- c
|
||||
//
|
||||
// Imagine that epochs are 2 slots and that epoch 1, 2, and 3 are finalized. Checkpoint roots would
|
||||
// be c, e, and g. In this scenario, c was a finalized checkpoint root but no block built upon it so
|
||||
// it should not be considered "final and canonical" in the view at slot 6.
|
||||
|
@ -214,6 +214,7 @@ func (s *Service) ExchangeTransitionConfiguration(
|
||||
//
|
||||
// Spec code:
|
||||
// def get_pow_block_at_terminal_total_difficulty(pow_chain: Dict[Hash32, PowBlock]) -> Optional[PowBlock]:
|
||||
//
|
||||
// # `pow_chain` abstractly represents all blocks in the PoW chain
|
||||
// for block in pow_chain:
|
||||
// parent = pow_chain[block.parent_hash]
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
// This should only be called at the start of every slot interval.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// # Reset store.proposer_boost_root if this is a new slot
|
||||
// if current_slot > previous_slot:
|
||||
// store.proposer_boost_root = Root()
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
// J -- K -- L
|
||||
//
|
||||
// And every block in the Fork choice is optimistic.
|
||||
//
|
||||
func TestPruneInvalid(t *testing.T) {
|
||||
tests := []struct {
|
||||
root [32]byte // the root of the new INVALID block
|
||||
@ -290,8 +289,8 @@ func TestSetOptimisticToInvalid_CorrectChildren(t *testing.T) {
|
||||
// \ \--------------E
|
||||
// \
|
||||
// ----------------------F -- G
|
||||
// B is INVALID
|
||||
//
|
||||
// B is INVALID
|
||||
func TestSetOptimisticToInvalid_ForkAtMerge(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
f := setup(1, 1)
|
||||
@ -343,8 +342,8 @@ func TestSetOptimisticToInvalid_ForkAtMerge(t *testing.T) {
|
||||
// \ \--------------E
|
||||
// \
|
||||
// --A -------------------------F -- G
|
||||
// B is INVALID
|
||||
//
|
||||
// B is INVALID
|
||||
func TestSetOptimisticToInvalid_ForkAtMerge_bis(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
f := setup(1, 1)
|
||||
|
@ -217,6 +217,7 @@ func TestStore_Prune_ReturnEarly(t *testing.T) {
|
||||
//
|
||||
// - 1
|
||||
// /
|
||||
//
|
||||
// -- 0 -- 2
|
||||
//
|
||||
// And we finalize 1. As a result only 1 should survive
|
||||
@ -246,8 +247,6 @@ func TestStore_Prune_NoDanglingBranch(t *testing.T) {
|
||||
// A -- B G -- H -- I
|
||||
// \ \
|
||||
// J -- K -- L
|
||||
//
|
||||
//
|
||||
func TestStore_tips(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
f := setup(1, 1)
|
||||
|
@ -53,17 +53,18 @@ func TestStore_UpdateUnrealizedCheckpoints(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Epoch 2 | Epoch 3
|
||||
//
|
||||
// |
|
||||
// C |
|
||||
// / |
|
||||
//
|
||||
// A <-- B |
|
||||
//
|
||||
// \ |
|
||||
// ---- D
|
||||
//
|
||||
// B is the first block that justifies A.
|
||||
//
|
||||
func TestStore_LongFork(t *testing.T) {
|
||||
f := setup(1, 1)
|
||||
ctx := context.Background()
|
||||
@ -104,18 +105,17 @@ func TestStore_LongFork(t *testing.T) {
|
||||
require.Equal(t, [32]byte{'c'}, headRoot)
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Epoch 1 Epoch 2 Epoch 3
|
||||
// | |
|
||||
// | |
|
||||
//
|
||||
// A <-- B <-- C <-- D <-- E <-- F <-- G <-- H |
|
||||
//
|
||||
// | \ |
|
||||
// | --------------- I
|
||||
// | |
|
||||
//
|
||||
// E justifies A. G justifies E.
|
||||
//
|
||||
func TestStore_NoDeadLock(t *testing.T) {
|
||||
f := setup(0, 0)
|
||||
ctx := context.Background()
|
||||
@ -197,7 +197,6 @@ func TestStore_NoDeadLock(t *testing.T) {
|
||||
// |
|
||||
//
|
||||
// D justifies and comes late.
|
||||
//
|
||||
func TestStore_ForkNextEpoch(t *testing.T) {
|
||||
resetCfg := features.InitWithReset(&features.Flags{
|
||||
EnableDefensivePull: true,
|
||||
|
@ -283,6 +283,7 @@ func (ns *Server) GetSyncStatus(ctx context.Context, _ *emptypb.Empty) (*ethpb.S
|
||||
|
||||
// GetHealth returns node health status in http status codes. Useful for load balancers.
|
||||
// Response Usage:
|
||||
//
|
||||
// "200":
|
||||
// description: Node is ready
|
||||
// "206":
|
||||
|
@ -186,6 +186,7 @@ func warnIfFeeRecipientDiffers(payload *enginev1.ExecutionPayload, feeRecipient
|
||||
//
|
||||
// Spec code:
|
||||
// def get_terminal_pow_block(pow_chain: Dict[Hash32, PowBlock]) -> Optional[PowBlock]:
|
||||
//
|
||||
// if TERMINAL_BLOCK_HASH != Hash32():
|
||||
// # Terminal block hash override takes precedence over terminal total difficulty
|
||||
// if TERMINAL_BLOCK_HASH in pow_chain:
|
||||
@ -214,6 +215,7 @@ func (vs *Server) getTerminalBlockHashIfExists(ctx context.Context, transitionTi
|
||||
|
||||
// activationEpochNotReached returns true if activation epoch has not been reach.
|
||||
// Which satisfy the following conditions in spec:
|
||||
//
|
||||
// is_terminal_block_hash_set = TERMINAL_BLOCK_HASH != Hash32()
|
||||
// is_activation_epoch_reached = get_current_epoch(state) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
|
||||
// if is_terminal_block_hash_set and not is_activation_epoch_reached:
|
||||
|
@ -301,7 +301,6 @@ func (m *MaxSpanChunksSlice) CheckSlashable(
|
||||
// 4 down to 3. First, we find out which chunk epoch 4 falls into, which is calculated as:
|
||||
// chunk_idx = (epoch % H) / C = (4 % 2) / 2 = 0
|
||||
//
|
||||
//
|
||||
// val0 val1 val2
|
||||
// { } { } { }
|
||||
// chunk_0_for_validators_0_to_3 = [[2, 2], [2, 2], [2, 2]]
|
||||
|
@ -47,7 +47,6 @@ func DefaultParams() *Parameters {
|
||||
// span = [-, -, -, -, -, -]
|
||||
// chunked = [[-, -], [-, -], [-, -]]
|
||||
// |-> epoch 4, chunk idx 2
|
||||
//
|
||||
func (p *Parameters) chunkIndex(epoch types.Epoch) uint64 {
|
||||
return uint64(epoch.Mod(uint64(p.historyLength)).Div(p.chunkSize))
|
||||
}
|
||||
@ -68,7 +67,6 @@ func (p *Parameters) validatorChunkIndex(validatorIndex types.ValidatorIndex) ui
|
||||
// [[-, -, -], [-, -, -], [-, -, -], ...]
|
||||
// |
|
||||
// -> first epoch of chunk 1 equals 3
|
||||
//
|
||||
func (p *Parameters) firstEpoch(chunkIndex uint64) types.Epoch {
|
||||
return types.Epoch(chunkIndex * p.chunkSize)
|
||||
}
|
||||
@ -82,7 +80,6 @@ func (p *Parameters) firstEpoch(chunkIndex uint64) types.Epoch {
|
||||
// [[-, -, -], [-, -, -], [-, -, -], ...]
|
||||
// |
|
||||
// -> last epoch of chunk 1 equals 5
|
||||
//
|
||||
func (p *Parameters) lastEpoch(chunkIndex uint64) types.Epoch {
|
||||
return p.firstEpoch(chunkIndex).Add(p.chunkSize - 1)
|
||||
}
|
||||
@ -109,7 +106,6 @@ func (p *Parameters) lastEpoch(chunkIndex uint64) types.Epoch {
|
||||
// { } { } { }
|
||||
// [-, -, -, -, -, -, -, -, -]
|
||||
// |-> epoch 1 for val2
|
||||
//
|
||||
func (p *Parameters) cellIndex(validatorIndex types.ValidatorIndex, epoch types.Epoch) uint64 {
|
||||
validatorChunkOffset := p.validatorOffset(validatorIndex)
|
||||
chunkOffset := p.chunkOffset(epoch)
|
||||
@ -144,7 +140,6 @@ func (p *Parameters) validatorOffset(validatorIndex types.ValidatorIndex) uint64
|
||||
// So every span has 4 chunks. Then, we have a disk key calculated by
|
||||
//
|
||||
// validatorChunkIndex * width + chunkIndex = 2*4 + 2 = 10
|
||||
//
|
||||
func (p *Parameters) flatSliceID(validatorChunkIndex, chunkIndex uint64) []byte {
|
||||
width := p.historyLength.Div(p.chunkSize)
|
||||
return ssz.MarshalUint64(make([]byte, 0), uint64(width.Mul(validatorChunkIndex).Add(chunkIndex)))
|
||||
|
@ -360,6 +360,7 @@ func TestLoadBlocks_BadStart(t *testing.T) {
|
||||
|
||||
// tree1 constructs the following tree:
|
||||
// B0 - B1 - - B3 -- B5
|
||||
//
|
||||
// \- B2 -- B4 -- B6 ----- B8
|
||||
// \- B7
|
||||
func tree1(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][32]byte, []*ethpb.SignedBeaconBlock, error) {
|
||||
@ -449,6 +450,7 @@ func tree1(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][32]byte,
|
||||
|
||||
// tree2 constructs the following tree:
|
||||
// B0 - B1
|
||||
//
|
||||
// \- B2
|
||||
// \- B2
|
||||
// \- B2
|
||||
@ -531,6 +533,7 @@ func tree2(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][32]byte,
|
||||
|
||||
// tree3 constructs the following tree:
|
||||
// B0 - B1
|
||||
//
|
||||
// \- B2
|
||||
// \- B2
|
||||
// \- B2
|
||||
@ -607,6 +610,7 @@ func tree3(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][32]byte,
|
||||
|
||||
// tree4 constructs the following tree:
|
||||
// B0
|
||||
//
|
||||
// \- B2
|
||||
// \- B2
|
||||
// \- B2
|
||||
|
@ -32,8 +32,11 @@ import (
|
||||
)
|
||||
|
||||
// /- b1 - b2
|
||||
//
|
||||
// b0
|
||||
//
|
||||
// \- b3
|
||||
//
|
||||
// Test b1 was missing then received and we can process b0 -> b1 -> b2
|
||||
func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks1(t *testing.T) {
|
||||
db := dbtest.SetupDB(t)
|
||||
@ -349,8 +352,11 @@ func TestRegularSyncBeaconBlockSubscriber_DoNotReprocessBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
// /- b1 - b2 - b5
|
||||
//
|
||||
// b0
|
||||
//
|
||||
// \- b3 - b4
|
||||
//
|
||||
// Test b2 and b3 were missed, after receiving them we can process 2 chains.
|
||||
func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks_2Chains(t *testing.T) {
|
||||
db := dbtest.SetupDB(t)
|
||||
|
@ -18,7 +18,6 @@ This means it is the exact mirror of a token bucket.
|
||||
n := b.Add(1)
|
||||
// n == 0
|
||||
|
||||
|
||||
A Collector is a convenient way to keep track of multiple LeakyBucket's.
|
||||
Buckets are associated with string keys for fast lookup. It can dynamically
|
||||
add new buckets and automatically remove them as they become empty, freeing
|
||||
|
@ -296,6 +296,7 @@ func SplitCommaSeparated(arr []string) []string {
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
// def get_split_offset(list_size: int, chunks: int, index: int) -> int:
|
||||
//
|
||||
// """
|
||||
// Returns a value such that for a list L, chunk count k and index i,
|
||||
// split(L, k)[i] == L[get_split_offset(len(L), k, i): get_split_offset(len(L), k, i+1)]
|
||||
|
@ -101,6 +101,7 @@ func (m *SparseMerkleTrie) Items() [][]byte {
|
||||
}
|
||||
|
||||
// HashTreeRoot of the Merkle trie as defined in the deposit contract.
|
||||
//
|
||||
// Spec Definition:
|
||||
// sha256(concat(node, self.to_little_endian_64(self.deposit_count), slice(zero_bytes32, start=0, len=24)))
|
||||
func (m *SparseMerkleTrie) HashTreeRoot() ([32]byte, error) {
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
// signed by the deposit key.
|
||||
//
|
||||
// Spec details about general deposit workflow:
|
||||
//
|
||||
// To submit a deposit:
|
||||
//
|
||||
// - Pack the validator's initialization parameters into deposit_data, a Deposit_Data SSZ object.
|
||||
@ -68,8 +69,10 @@ func DepositInput(depositKey, withdrawalKey bls.SecretKey, amountInGwei uint64)
|
||||
// address.
|
||||
//
|
||||
// The specification is as follows:
|
||||
//
|
||||
// withdrawal_credentials[:1] == BLS_WITHDRAWAL_PREFIX_BYTE
|
||||
// withdrawal_credentials[1:] == hash(withdrawal_pubkey)[1:]
|
||||
//
|
||||
// where withdrawal_credentials is of type bytes32.
|
||||
func WithdrawalCredentialsHash(withdrawalKey bls.SecretKey) []byte {
|
||||
h := hash.Hash(withdrawalKey.PublicKey().Marshal())
|
||||
|
@ -3,5 +3,4 @@
|
||||
// verifying and aggregating BLS signatures used by Ethereum.
|
||||
//
|
||||
// This implementation uses the library written by Supranational, blst.
|
||||
//
|
||||
package blst
|
||||
|
@ -67,6 +67,7 @@ func IsZero(sKey []byte) bool {
|
||||
//
|
||||
// In IETF draft BLS specification:
|
||||
// Sign(SK, message) -> signature: a signing algorithm that generates
|
||||
//
|
||||
// a deterministic signature given a secret key SK and a message.
|
||||
//
|
||||
// In Ethereum proof of stake specification:
|
||||
|
@ -85,6 +85,7 @@ func MultipleSignaturesFromBytes(multiSigs [][]byte) ([]common.Signature, error)
|
||||
//
|
||||
// In IETF draft BLS specification:
|
||||
// Verify(PK, message, signature) -> VALID or INVALID: a verification
|
||||
//
|
||||
// algorithm that outputs VALID if signature is a valid signature of
|
||||
// message under public key PK, and INVALID otherwise.
|
||||
//
|
||||
@ -103,6 +104,7 @@ func (s *Signature) Verify(pubKey common.PublicKey, msg []byte) bool {
|
||||
//
|
||||
// In IETF draft BLS specification:
|
||||
// AggregateVerify((PK_1, message_1), ..., (PK_n, message_n),
|
||||
//
|
||||
// signature) -> VALID or INVALID: an aggregate verification
|
||||
// algorithm that outputs VALID if signature is a valid aggregated
|
||||
// signature for a collection of public keys and messages, and
|
||||
@ -134,6 +136,7 @@ func (s *Signature) AggregateVerify(pubKeys []common.PublicKey, msgs [][32]byte)
|
||||
//
|
||||
// In IETF draft BLS specification:
|
||||
// FastAggregateVerify(PK_1, ..., PK_n, message, signature) -> VALID
|
||||
//
|
||||
// or INVALID: a verification algorithm for the aggregate of multiple
|
||||
// signatures on the same message. This function is faster than
|
||||
// AggregateVerify.
|
||||
@ -156,6 +159,7 @@ func (s *Signature) FastAggregateVerify(pubKeys []common.PublicKey, msg [32]byte
|
||||
//
|
||||
// Spec code:
|
||||
// def eth2_fast_aggregate_verify(pubkeys: Sequence[BLSPubkey], message: Bytes32, signature: BLSSignature) -> bool:
|
||||
//
|
||||
// """
|
||||
// Wrapper to ``bls.FastAggregateVerify`` accepting the ``G2_POINT_AT_INFINITY`` signature when ``pubkeys`` is empty.
|
||||
// """
|
||||
|
@ -247,7 +247,7 @@ func deepValueBaseTypeEqual(v1, v2 reflect.Value) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// DeepEqual reports whether two SSZ-able values x and y are ``deeply equal,'' defined as follows:
|
||||
// DeepEqual reports whether two SSZ-able values x and y are “deeply equal,” defined as follows:
|
||||
// Two values of identical type are deeply equal if one of the following cases applies:
|
||||
//
|
||||
// Values of distinct types are never deeply equal.
|
||||
|
@ -1,6 +1,6 @@
|
||||
base:
|
||||
language: go
|
||||
version: 1.18
|
||||
version: 1.19
|
||||
build_tags:
|
||||
- fuzz
|
||||
- develop
|
||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module github.com/prysmaticlabs/prysm/v3
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
contrib.go.opencensus.io/exporter/jaeger v0.2.1
|
||||
|
@ -186,8 +186,10 @@ func createDepositData(privKey bls.SecretKey, pubKey bls.PublicKey) (*ethpb.Depo
|
||||
// address.
|
||||
//
|
||||
// The specification is as follows:
|
||||
//
|
||||
// withdrawal_credentials[:1] == BLS_WITHDRAWAL_PREFIX_BYTE
|
||||
// withdrawal_credentials[1:] == hash(withdrawal_pubkey)[1:]
|
||||
//
|
||||
// where withdrawal_credentials is of type bytes32.
|
||||
func withdrawalCredentialsHash(pubKey []byte) []byte {
|
||||
h := hash.Hash(pubKey)
|
||||
|
@ -568,7 +568,6 @@ func (r *testRunner) executeProvidedEvaluators(currentEpoch uint64, conns []*grp
|
||||
// Along with that we will also take a single lighthouse node and its validator offline.
|
||||
// After 1 epoch we will then attempt to bring it online again.
|
||||
//
|
||||
//
|
||||
// 2) Then we will start testing optimistic sync by engaging our engine proxy.
|
||||
// After the proxy has been sending `SYNCING` responses to the beacon node, we
|
||||
// will test this with our optimistic sync evaluator to ensure everything works
|
||||
|
@ -65,6 +65,7 @@ func AbsoluteValueSlotDifference(x, y types.Slot) uint64 {
|
||||
// ToEpoch returns the epoch number of the input slot.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_epoch_at_slot(slot: Slot) -> Epoch:
|
||||
// """
|
||||
// Return the epoch number at ``slot``.
|
||||
@ -78,6 +79,7 @@ func ToEpoch(slot types.Slot) types.Epoch {
|
||||
// current epoch.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def compute_start_slot_at_epoch(epoch: Epoch) -> Slot:
|
||||
// """
|
||||
// Return the start slot of ``epoch``.
|
||||
@ -213,6 +215,7 @@ func PrevSlot(slot types.Slot) types.Slot {
|
||||
//
|
||||
// Spec code:
|
||||
// def compute_sync_committee_period(epoch: Epoch) -> uint64:
|
||||
//
|
||||
// return epoch // EPOCHS_PER_SYNC_COMMITTEE_PERIOD
|
||||
func SyncCommitteePeriod(e types.Epoch) uint64 {
|
||||
return uint64(e / params.BeaconConfig().EpochsPerSyncCommitteePeriod)
|
||||
|
@ -26,6 +26,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
// "Software Quality Metrics to Identify Risk" by Thomas McCabe Jr.
|
||||
//
|
||||
// 1 - 10 Simple procedure, little risk
|
||||
//
|
||||
// 11 - 20 More complex, moderate risk
|
||||
// 21 - 50 Complex, high risk
|
||||
// > 50 Untestable code, very high risk
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Block tree graph viz
|
||||
/*
|
||||
*
|
||||
* Given a DB, start slot and end slot. This tool computes the graphviz data
|
||||
* needed to construct the block tree in graphviz data format. Then one can paste
|
||||
* the data in a Graph rendering engine (ie. http://www.webgraphviz.com/) to see the visual format.
|
||||
|
||||
- Block tree graph viz
|
||||
*
|
||||
- Given a DB, start slot and end slot. This tool computes the graphviz data
|
||||
- needed to construct the block tree in graphviz data format. Then one can paste
|
||||
- the data in a Graph rendering engine (ie. http://www.webgraphviz.com/) to see the visual format.
|
||||
*/
|
||||
package main
|
||||
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
|
||||
// A basic tool to extract genesis.ssz from existing beaconchain.db.
|
||||
// ex:
|
||||
//
|
||||
// bazel run //tools/interop/export-genesis:export-genesis -- /tmp/data/beaconchaindata /tmp/genesis.ssz
|
||||
func main() {
|
||||
if len(os.Args) < 3 {
|
||||
|
@ -1,4 +1,5 @@
|
||||
/**
|
||||
/*
|
||||
*
|
||||
Tool for replaying http requests from a file of base64 encoded, line-delimited
|
||||
Go http raw requests. Credits to https://gist.github.com/kasey/c9e663eae5baebbf8fbe548c2b1d961b.
|
||||
*/
|
||||
|
@ -247,6 +247,7 @@ func (v *validator) saveAttesterIndexToData(data *ethpb.AttestationData, index t
|
||||
}
|
||||
|
||||
// waitOneThirdOrValidBlock waits until (a) or (b) whichever comes first:
|
||||
//
|
||||
// (a) the validator has received a valid block that is the same slot as input slot
|
||||
// (b) one-third of the slot has transpired (SECONDS_PER_SLOT / 3 seconds after the start of slot)
|
||||
func (v *validator) waitOneThirdOrValidBlock(ctx context.Context, slot types.Slot) {
|
||||
|
@ -177,6 +177,7 @@ func validateMetadata(ctx context.Context, validatorDB db.Database, interchangeJ
|
||||
// "0x2932232930: {
|
||||
// SignedBlocks: [Slot: 5, Slot: 6, Slot: 7],
|
||||
// },
|
||||
//
|
||||
// "0x2932232930: {
|
||||
// SignedBlocks: [Slot: 5, Slot: 10, Slot: 11],
|
||||
// }
|
||||
@ -209,6 +210,7 @@ func parseBlocksForUniquePublicKeys(data []*format.ProtectionData) (map[[fieldpa
|
||||
// "0x2932232930: {
|
||||
// SignedAttestations: [{Source: 5, Target: 6}, {Source: 6, Target: 7}],
|
||||
// },
|
||||
//
|
||||
// "0x2932232930: {
|
||||
// SignedAttestations: [{Source: 5, Target: 6}],
|
||||
// }
|
||||
|
Loading…
Reference in New Issue
Block a user