mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
defer payload attribute computation (#14644)
* defer payload attribute computation * fire payload event on skipped slots * changelog * fix test and missing version attr * fix lint * deepsource * mv head block lookup for missed slots to streamer --------- Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
@@ -10,8 +10,12 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/consensus-types/payload-attribute",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//consensus-types:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
|
||||
@@ -38,6 +38,16 @@ func (a *data) Withdrawals() ([]*enginev1.Withdrawal, error) {
|
||||
return a.withdrawals, nil
|
||||
}
|
||||
|
||||
func (a *data) ParentBeaconBlockRoot() ([]byte, error) {
|
||||
if len(a.parentBeaconBlockRoot) == 0 {
|
||||
return nil, errNoParentRoot
|
||||
}
|
||||
if a.version < version.Deneb {
|
||||
return nil, consensus_types.ErrNotSupported("ParentBeaconBlockRoot", a.version)
|
||||
}
|
||||
return a.parentBeaconBlockRoot, nil
|
||||
}
|
||||
|
||||
// PbV1 returns the payload attribute in version 1.
|
||||
func (a *data) PbV1() (*enginev1.PayloadAttributes, error) {
|
||||
if a == nil {
|
||||
@@ -97,6 +107,9 @@ func (a *data) PbV3() (*enginev1.PayloadAttributesV3, error) {
|
||||
|
||||
// IsEmpty returns whether the given payload attribute is empty
|
||||
func (a *data) IsEmpty() bool {
|
||||
if a == nil {
|
||||
return true
|
||||
}
|
||||
if len(a.PrevRandao()) != 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ type Attributer interface {
|
||||
Timestamp() uint64
|
||||
SuggestedFeeRecipient() []byte
|
||||
Withdrawals() ([]*enginev1.Withdrawal, error)
|
||||
ParentBeaconBlockRoot() ([]byte, error)
|
||||
PbV1() (*enginev1.PayloadAttributes, error)
|
||||
PbV2() (*enginev1.PayloadAttributesV2, error)
|
||||
PbV3() (*enginev1.PayloadAttributesV3, error)
|
||||
|
||||
@@ -2,7 +2,11 @@ package payloadattribute
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
field_params "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
|
||||
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
||||
)
|
||||
@@ -23,6 +27,7 @@ type data struct {
|
||||
var (
|
||||
errNilPayloadAttribute = errors.New("received nil payload attribute")
|
||||
errUnsupportedPayloadAttribute = errors.New("unsupported payload attribute")
|
||||
errNoParentRoot = errors.New("parent root is empty")
|
||||
)
|
||||
|
||||
// New returns a new payload attribute with the given input object.
|
||||
@@ -89,3 +94,16 @@ func initPayloadAttributeFromV3(a *enginev1.PayloadAttributesV3) (Attributer, er
|
||||
parentBeaconBlockRoot: a.ParentBeaconBlockRoot,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// EventData holds the values for a PayloadAttributes event.
|
||||
type EventData struct {
|
||||
ProposerIndex primitives.ValidatorIndex
|
||||
ProposalSlot primitives.Slot
|
||||
ParentBlockNumber uint64
|
||||
ParentBlockRoot []byte
|
||||
ParentBlockHash []byte
|
||||
Attributer Attributer
|
||||
HeadState state.BeaconState
|
||||
HeadBlock interfaces.ReadOnlySignedBeaconBlock
|
||||
HeadRoot [field_params.RootLength]byte
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user