mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-31 16:21:21 +00:00
3ab373787e
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
33 lines
839 B
Go
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
|
|
}
|