2022-05-09 13:02:34 +00:00
|
|
|
package state_native
|
2022-01-13 11:23:53 +00:00
|
|
|
|
|
|
|
import (
|
2023-02-10 19:36:19 +00:00
|
|
|
"math/big"
|
|
|
|
|
2023-03-17 18:52:56 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces"
|
|
|
|
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/runtime/version"
|
2022-01-13 11:23:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// LatestExecutionPayloadHeader of the beacon state.
|
2022-10-12 16:39:19 +00:00
|
|
|
func (b *BeaconState) LatestExecutionPayloadHeader() (interfaces.ExecutionData, error) {
|
|
|
|
if b.version < version.Bellatrix {
|
2022-05-09 13:02:34 +00:00
|
|
|
return nil, errNotSupported("LatestExecutionPayloadHeader", b.version)
|
|
|
|
}
|
|
|
|
|
2022-01-13 11:23:53 +00:00
|
|
|
b.lock.RLock()
|
|
|
|
defer b.lock.RUnlock()
|
|
|
|
|
2022-10-12 16:39:19 +00:00
|
|
|
if b.version == version.Bellatrix {
|
|
|
|
return blocks.WrappedExecutionPayloadHeader(b.latestExecutionPayloadHeaderVal())
|
|
|
|
}
|
2023-02-10 19:36:19 +00:00
|
|
|
return blocks.WrappedExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapellaVal(), big.NewInt(0))
|
2022-01-13 11:23:53 +00:00
|
|
|
}
|
|
|
|
|
2022-02-01 00:32:39 +00:00
|
|
|
// latestExecutionPayloadHeaderVal of the beacon state.
|
2022-01-13 11:23:53 +00:00
|
|
|
// This assumes that a lock is already held on BeaconState.
|
2022-06-22 11:08:06 +00:00
|
|
|
func (b *BeaconState) latestExecutionPayloadHeaderVal() *enginev1.ExecutionPayloadHeader {
|
2022-02-01 00:32:39 +00:00
|
|
|
return ethpb.CopyExecutionPayloadHeader(b.latestExecutionPayloadHeader)
|
2022-01-13 11:23:53 +00:00
|
|
|
}
|
2022-10-12 16:39:19 +00:00
|
|
|
|
|
|
|
// latestExecutionPayloadHeaderCapellaVal of the beacon state.
|
|
|
|
// This assumes that a lock is already held on BeaconState.
|
|
|
|
func (b *BeaconState) latestExecutionPayloadHeaderCapellaVal() *enginev1.ExecutionPayloadHeaderCapella {
|
|
|
|
return ethpb.CopyExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapella)
|
|
|
|
}
|