mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
7fa3ebfaa8
* Add historical summaries to state and processing * Process historical roots test * Passing spec tests * Fix shas and tests * Fix mainnet spectest sha * Fix tests * Update beacon-chain/core/epoch/epoch_processing.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update beacon-chain/core/epoch/epoch_processing_test.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update proto/prysm/v1alpha1/beacon_state.proto Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update beacon-chain/state/state-native/hasher.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Radek's feedback * Getters error * Dont return * Fix else * Fix tests * Fix test * Rm white space Co-authored-by: Radosław Kapka <rkapka@wp.pl>
90 lines
3.2 KiB
Go
90 lines
3.2 KiB
Go
package execution
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/time"
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
|
state_native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
|
"github.com/prysmaticlabs/prysm/v3/config/params"
|
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
// UpgradeToBellatrix updates inputs a generic state to return the version Bellatrix state.
|
|
// It inserts an empty `ExecutionPayloadHeader` into the state.
|
|
func UpgradeToBellatrix(state state.BeaconState) (state.BeaconState, error) {
|
|
epoch := time.CurrentEpoch(state)
|
|
|
|
currentSyncCommittee, err := state.CurrentSyncCommittee()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
nextSyncCommittee, err := state.NextSyncCommittee()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
prevEpochParticipation, err := state.PreviousEpochParticipation()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
currentEpochParticipation, err := state.CurrentEpochParticipation()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
inactivityScores, err := state.InactivityScores()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
hrs, err := state.HistoricalRoots()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
s := ðpb.BeaconStateBellatrix{
|
|
GenesisTime: state.GenesisTime(),
|
|
GenesisValidatorsRoot: state.GenesisValidatorsRoot(),
|
|
Slot: state.Slot(),
|
|
Fork: ðpb.Fork{
|
|
PreviousVersion: state.Fork().CurrentVersion,
|
|
CurrentVersion: params.BeaconConfig().BellatrixForkVersion,
|
|
Epoch: epoch,
|
|
},
|
|
LatestBlockHeader: state.LatestBlockHeader(),
|
|
BlockRoots: state.BlockRoots(),
|
|
StateRoots: state.StateRoots(),
|
|
HistoricalRoots: hrs,
|
|
Eth1Data: state.Eth1Data(),
|
|
Eth1DataVotes: state.Eth1DataVotes(),
|
|
Eth1DepositIndex: state.Eth1DepositIndex(),
|
|
Validators: state.Validators(),
|
|
Balances: state.Balances(),
|
|
RandaoMixes: state.RandaoMixes(),
|
|
Slashings: state.Slashings(),
|
|
PreviousEpochParticipation: prevEpochParticipation,
|
|
CurrentEpochParticipation: currentEpochParticipation,
|
|
JustificationBits: state.JustificationBits(),
|
|
PreviousJustifiedCheckpoint: state.PreviousJustifiedCheckpoint(),
|
|
CurrentJustifiedCheckpoint: state.CurrentJustifiedCheckpoint(),
|
|
FinalizedCheckpoint: state.FinalizedCheckpoint(),
|
|
InactivityScores: inactivityScores,
|
|
CurrentSyncCommittee: currentSyncCommittee,
|
|
NextSyncCommittee: nextSyncCommittee,
|
|
LatestExecutionPayloadHeader: &enginev1.ExecutionPayloadHeader{
|
|
ParentHash: make([]byte, 32),
|
|
FeeRecipient: make([]byte, 20),
|
|
StateRoot: make([]byte, 32),
|
|
ReceiptsRoot: make([]byte, 32),
|
|
LogsBloom: make([]byte, 256),
|
|
PrevRandao: make([]byte, 32),
|
|
BlockNumber: 0,
|
|
GasLimit: 0,
|
|
GasUsed: 0,
|
|
Timestamp: 0,
|
|
BaseFeePerGas: make([]byte, 32),
|
|
BlockHash: make([]byte, 32),
|
|
TransactionsRoot: make([]byte, 32),
|
|
},
|
|
}
|
|
|
|
return state_native.InitializeFromProtoUnsafeBellatrix(s)
|
|
}
|