mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-19 19:09:08 +00:00
146fa48454
* use ForkedHashedBeaconState in StateData * fix FAR_FUTURE_EPOCH -> slot overflow; almost always use assign() * avoid stack allocation in maybeUpgradeStateToAltair() * create and use dispatch functions for check_attester_slashing(), check_proposer_slashing(), and check_voluntary_exit() * use getStateRoot() instead of various state.data.hbsPhase0.root * remove withStateVars.hashedState(), which doesn't work as a design anymore * introduce spec/datatypes/altair into beacon_chain_db * fix inefficient codegen for getStateField(largeStateField) * state_transition_slots() doesn't either need/use blocks or runtime presets * combine process_slots(HBS)/state_transition_slots(HBS) which differ only in last-slot htr optimization * getStateField(StateData, ...) was replaced by getStateField(ForkedHashedBeaconState, ...) * fix rollback * switch some state_transition(), process_slots, makeTestBlocks(), etc to use ForkedHashedBeaconState * remove state_transition(phase0.HashedBeaconState) * remove process_slots(phase0.HashedBeaconState) * remove state_transition_block(phase0.HashedBeaconState) * remove unused callWithBS(); separate case expression from if statement * switch back from nested-ref-object construction to (ref Foo)(Bar())
47 lines
1.6 KiB
Nim
47 lines
1.6 KiB
Nim
# beacon_chain
|
|
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
|
# Licensed and distributed under either of
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
import
|
|
os, strformat, chronicles,
|
|
./ssz_serialization,
|
|
../spec/[crypto, datatypes, digest],
|
|
../consensus_object_pools/block_pools_types
|
|
|
|
# Dump errors are generally not fatal where used currently - the code calling
|
|
# these functions, like most code, is not exception safe
|
|
template logErrors(body: untyped) =
|
|
try:
|
|
body
|
|
except CatchableError as err:
|
|
notice "Failed to write SSZ", dir, msg = err.msg
|
|
|
|
proc dump*(dir: string, v: AttestationData, validator: ValidatorPubKey) =
|
|
logErrors:
|
|
SSZ.saveFile(dir / &"att-{v.slot}-{v.index}-{shortLog(validator)}.ssz", v)
|
|
|
|
proc dump*(dir: string, v: SignedBeaconBlock) =
|
|
logErrors:
|
|
SSZ.saveFile(dir / &"block-{v.message.slot}-{shortLog(v.root)}.ssz", v)
|
|
|
|
proc dump*(dir: string, v: TrustedSignedBeaconBlock) =
|
|
logErrors:
|
|
SSZ.saveFile(dir / &"block-{v.message.slot}-{shortLog(v.root)}.ssz", v)
|
|
|
|
proc dump*(dir: string, v: HashedBeaconState, blck: BlockRef) =
|
|
logErrors:
|
|
SSZ.saveFile(
|
|
dir / &"state-{v.data.slot}-{shortLog(blck.root)}-{shortLog(v.root)}.ssz",
|
|
v.data)
|
|
|
|
proc dump*(dir: string, v: HashedBeaconState) =
|
|
logErrors:
|
|
SSZ.saveFile(
|
|
dir / &"state-{v.data.slot}-{shortLog(v.root)}.ssz",
|
|
v.data)
|