2022-05-09 13:02:34 +00:00
|
|
|
package state_native
|
|
|
|
|
|
|
|
import (
|
2022-07-13 01:49:38 +00:00
|
|
|
"github.com/pkg/errors"
|
2022-08-16 12:20:13 +00:00
|
|
|
nativetypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
|
|
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
|
|
|
_ "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
2022-05-09 13:02:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// SetLatestExecutionPayloadHeader for the beacon state.
|
2022-07-13 01:49:38 +00:00
|
|
|
func (b *BeaconState) SetLatestExecutionPayloadHeader(val interfaces.ExecutionData) error {
|
2022-05-09 13:02:34 +00:00
|
|
|
b.lock.Lock()
|
|
|
|
defer b.lock.Unlock()
|
|
|
|
|
2022-10-12 16:39:19 +00:00
|
|
|
if b.version < version.Bellatrix {
|
2022-05-09 13:02:34 +00:00
|
|
|
return errNotSupported("SetLatestExecutionPayloadHeader", b.version)
|
|
|
|
}
|
2022-10-12 16:39:19 +00:00
|
|
|
|
|
|
|
switch header := val.Proto().(type) {
|
|
|
|
case *enginev1.ExecutionPayloadHeader:
|
|
|
|
b.latestExecutionPayloadHeader = header
|
|
|
|
b.markFieldAsDirty(nativetypes.LatestExecutionPayloadHeader)
|
|
|
|
return nil
|
|
|
|
case *enginev1.ExecutionPayloadHeaderCapella:
|
|
|
|
b.latestExecutionPayloadHeaderCapella = header
|
|
|
|
b.markFieldAsDirty(nativetypes.LatestExecutionPayloadHeaderCapella)
|
|
|
|
return nil
|
|
|
|
default:
|
2022-07-13 01:49:38 +00:00
|
|
|
return errors.New("value must be an execution payload header")
|
|
|
|
}
|
2022-05-09 13:02:34 +00:00
|
|
|
}
|