erigon-pulse/cl/transition/machine/transition.go
a 3ab373787e
[caplin] extracting beacon state interface (#7910)
we need to extract this interface from the struct. 

i need to also break down the interface more, to better show what parts
the caching is used, move some functions from the cache state to the
underlying.


don't merge
2023-07-20 00:20:33 +02:00

33 lines
839 B
Go

package machine
import (
"github.com/ledgerwatch/erigon/cl/abstract"
"github.com/ledgerwatch/erigon/cl/cltypes"
)
// TransitionState will call impl..ProcessSlots, then impl.VerifyBlockSignature, then ProcessBlock, then impl.VerifyTransition
func TransitionState(impl Interface, s abstract.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
}