2023-06-11 21:50:02 +00:00
|
|
|
package machine
|
|
|
|
|
|
|
|
import (
|
2023-07-19 22:20:33 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cl/abstract"
|
2023-06-11 21:50:02 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cl/cltypes"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TransitionState will call impl..ProcessSlots, then impl.VerifyBlockSignature, then ProcessBlock, then impl.VerifyTransition
|
2023-07-19 22:20:33 +00:00
|
|
|
func TransitionState(impl Interface, s abstract.BeaconState, block *cltypes.SignedBeaconBlock) error {
|
2023-06-11 21:50:02 +00:00
|
|
|
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
|
|
|
|
}
|