mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
* Add the new Fulu state with the new field * fix the hasher for the fulu state * Fix ToProto() and ToProtoUnsafe() * Add the fields as shared * Add epoch transition code * short circuit the proposer cache to use the state * Marshal the state JSON * update spectests to 1.6.0-alpha.1 * Remove deneb and electra entries from blob schedule This was cherry picked from PR #15364 and edited to remove the minimal cases * Fix minimal tests * Increase deadling for processing blocks in spectests * Preston's review * review --------- Co-authored-by: terence tsao <terence@prysmaticlabs.com>
2.3 KiB
2.3 KiB
Adding a new field to the state
Note: Whenever only the name of a file is provided, it's assumed to be in the /beacon-chain/state/state-native package.
- Add a
BeaconState[Version]FieldCountconfiguration item to/config/params/config.goand set it in/config/params/mainnet_config.go. - Add the field to the
BeaconStatestruct inbeacon_state.go. Update the marshaling structs in the same file too. - Add the field's metadata to
/beacon-chain/state/state-native/types/types.go. - Add a getter and a setter for the field, either to existing
getter_XXX.go/setter_XXX.gofiles or create new ones if the field doesn't fit anywhere. Add the new getter and setter to/beacon-chain/state/interfaces.go. - Update state hashing in
hasher.go. - Update
ToProtoUnsafe()andToProto()functions and add a newProtobufBeaconState[Version]function, all ingetters_state.go. - If the field is a multi-value slice, update
multi_value_slices.go. - Update
spec_parameters.go. - Update
state_trie.go:- Add a
[version]Fieldsvariable that contains all fields of the new state version. - Add a
[version]SharedFieldRefCountconstant that represents the number of fields whose references are shared between states. - Add an
experimentalState[Version]SharedFieldCountRefconstant that represents the number of non multi-value slice fields whose references are shared between states. - Add the following functions:
InitializeFromProto[Version](),InitializeFromProtoUnsafe[Version](). - Update the following functions:
Copy(),initializeMerkleLayers(),RecordStateMetrics()(applies only to multi-value slice fields),rootSelector(),finalizerCleanup()(applies only to multi-value slice fields).
- Add a
- If the field is a slice, add it to the field map in
types.go. This only applies to large slices that need to be rehashed only in part. In particular, this mostly applies for arrays of objects, and not for arrays of basic SSZ types as these are not hashed by taking the root of each element. - If the field is a slice, update the
fieldConverters()function in/beacon-chain/state/fieldtrie/field_trie_helpers.go. The exact implementation will vary depending on a few factors (is the field similar to an existing one, is it a multi-value slice etc). This applies only for the slices as mentioned in the previous comment.