mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-08 03:51:20 +00:00
4d35e776da
start of abstracting the transition layer. incremental movements.
33 lines
846 B
Go
33 lines
846 B
Go
package machine
|
|
|
|
import (
|
|
"github.com/ledgerwatch/erigon/cl/cltypes"
|
|
"github.com/ledgerwatch/erigon/cl/phase1/core/state"
|
|
)
|
|
|
|
// TransitionState will call impl..ProcessSlots, then impl.VerifyBlockSignature, then ProcessBlock, then impl.VerifyTransition
|
|
func TransitionState(impl Interface, s *state.BeaconState, block *cltypes.SignedBeaconBlock) error {
|
|
currentBlock := block.Block
|
|
if err := impl.ProcessSlots(s, currentBlock.Slot); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := impl.VerifyBlockSignature(s, block); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Transition block
|
|
if err := ProcessBlock(impl, s, block); err != nil {
|
|
return err
|
|
}
|
|
|
|
// perform validation
|
|
if err := impl.VerifyTransition(s, currentBlock); err != nil {
|
|
return err
|
|
}
|
|
|
|
// if validation is successful, transition
|
|
s.SetPreviousStateRoot(currentBlock.StateRoot)
|
|
return nil
|
|
}
|