Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrForkNotFound = errors.New("version found in fork schedule but can't be matched to a named fork")
Functions ¶
This section is empty.
Types ¶
type VersionedUnmarshaler ¶
type VersionedUnmarshaler struct { Config *params.BeaconChainConfig // Fork aligns with the fork names in config/params/values.go Fork int // Version corresponds to the Version type defined in the beacon-chain spec, aka a "fork version number": // https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#custom-types Version [fieldparams.VersionLength]byte }
VersionedUnmarshaler represents the intersection of Configuration (eg mainnet, testnet) and Fork (eg phase0, altair). Using a detected VersionedUnmarshaler, a BeaconState or SignedBeaconBlock can be correctly unmarshaled without the need to hard code a concrete type in paths where only the marshaled bytes, or marshaled bytes and a version, are available.
func FromForkVersion ¶
func FromForkVersion(cv [fieldparams.VersionLength]byte) (*VersionedUnmarshaler, error)
FromForkVersion uses a lookup table to resolve a Version (from a beacon node api for instance, or obtained by peeking at the bytes of a marshaled BeaconState) to a VersionedUnmarshaler.
func FromState ¶
func FromState(marshaled []byte) (*VersionedUnmarshaler, error)
FromState exploits the fixed-size lower-order bytes in a BeaconState as a heuristic to obtain the value of the state.version field without first unmarshaling the BeaconState. The Version is then internally used to lookup the correct ConfigVersion.
func (*VersionedUnmarshaler) UnmarshalBeaconBlock ¶
func (cf *VersionedUnmarshaler) UnmarshalBeaconBlock(marshaled []byte) (interfaces.SignedBeaconBlock, error)
UnmarshalBeaconBlock uses internal knowledge in the VersionedUnmarshaler to pick the right concrete SignedBeaconBlock type, then Unmarshal()s the type and returns an instance of block.SignedBeaconBlock if successful.
func (*VersionedUnmarshaler) UnmarshalBeaconState ¶
func (cf *VersionedUnmarshaler) UnmarshalBeaconState(marshaled []byte) (s state.BeaconState, err error)
UnmarshalBeaconState uses internal knowledge in the VersionedUnmarshaler to pick the right concrete BeaconState type, then Unmarshal()s the type and returns an instance of state.BeaconState if successful.