Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution API Electra: requests as a sidecar #14492

Merged
merged 42 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3172789
wip
james-prysm Sep 30, 2024
806d783
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Sep 30, 2024
e5b8bd3
gaz
james-prysm Sep 30, 2024
5976923
rename field
james-prysm Oct 1, 2024
426f664
sammy review
james-prysm Oct 1, 2024
3b0c6e2
updating execution api request and reverting response back
james-prysm Oct 1, 2024
c215ba9
fixing linting
james-prysm Oct 1, 2024
ed07b75
changelog
james-prysm Oct 1, 2024
7517ac3
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 1, 2024
069f8c8
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 1, 2024
56dc32a
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 8, 2024
e7dfa24
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 8, 2024
e985dd8
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 9, 2024
015aeed
changelog
james-prysm Oct 9, 2024
81e4648
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 10, 2024
ef8281e
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 11, 2024
7767410
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 11, 2024
0e7a058
adding in serialization of requests
james-prysm Oct 11, 2024
575b528
code cleanup
james-prysm Oct 11, 2024
f854fdf
adding some happy path tests and fixing mock
james-prysm Oct 11, 2024
4a44864
mock still broken
james-prysm Oct 11, 2024
e533241
fixing linting
james-prysm Oct 11, 2024
539a633
updating name on proto
james-prysm Oct 11, 2024
2cec3a4
missed naming
james-prysm Oct 11, 2024
12f0a06
placeholder fix for TestClient_HTTP
james-prysm Oct 11, 2024
ff3170a
removing duplicate change log
james-prysm Oct 11, 2024
9dae721
adding in test for get payloadv4 as well as some tests
james-prysm Oct 14, 2024
8362871
added tests for execution client testing, fixed encode type
james-prysm Oct 14, 2024
43e01c4
adding comment for placeholder test
james-prysm Oct 14, 2024
f7ef1f3
fixing test and addressing feedback
james-prysm Oct 14, 2024
b41b707
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 14, 2024
7438ba2
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 15, 2024
040e48c
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 15, 2024
c24825a
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 15, 2024
9cc52a3
feedback
james-prysm Oct 15, 2024
ad56480
flipping the test names, was used in reverse
james-prysm Oct 15, 2024
5f95c3d
feedback from kasey
james-prysm Oct 15, 2024
8ee48ca
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 15, 2024
6c8baf5
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 16, 2024
0580bb5
reverting switch back to if statements to fix bug
james-prysm Oct 16, 2024
bea42f4
Merge branch 'develop' into execution-request-sidecar-electra
james-prysm Oct 16, 2024
2ffb01b
lint
james-prysm Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions beacon-chain/execution/engine_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ func (s *Service) ForkchoiceUpdated(

func getPayloadMethodAndMessage(slot primitives.Slot) (string, proto.Message) {
james-prysm marked this conversation as resolved.
Show resolved Hide resolved
pe := slots.ToEpoch(slot)
if pe >= params.BeaconConfig().ElectraForkEpoch {
return GetPayloadMethodV4, &pb.ExecutionEnvelopeElectra{}
}
if pe >= params.BeaconConfig().DenebForkEpoch {
return GetPayloadMethodV3, &pb.ExecutionPayloadDenebWithValueAndBlobsBundle{}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func setExecutionData(ctx context.Context, blk interfaces.SignedBeaconBlock, loc
log.WithError(err).Warn("Proposer: failed to retrieve header from BuilderBid")
return local.Bid, local.BlobsBundle, setLocalExecution(blk, local)
}
//TODO: add execution requests here.
if bid.Version() >= version.Deneb {
builderKzgCommitments, err = bid.BlobKzgCommitments()
if err != nil {
Expand Down Expand Up @@ -353,12 +354,19 @@ func setLocalExecution(blk interfaces.SignedBeaconBlock, local *blocks.GetPayloa
if local.BlobsBundle != nil {
kzgCommitments = local.BlobsBundle.KzgCommitments
}
if local.ExecutionRequests != nil {
if err := blk.SetExecutionRequests(local.ExecutionRequests); err != nil {
return errors.Wrap(err, "could not set execution requests")
}
}

return setExecution(blk, local.ExecutionData, false, kzgCommitments)
}

// setBuilderExecution sets the execution context for a builder's beacon block.
// It delegates to setExecution for the actual work.
func setBuilderExecution(blk interfaces.SignedBeaconBlock, execution interfaces.ExecutionData, builderKzgCommitments [][]byte) error {
// TODO #14344: add execution requests for electra
return setExecution(blk, execution, true, builderKzgCommitments)
}

Expand Down
15 changes: 14 additions & 1 deletion consensus-types/blocks/get_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type GetPayloadResponse struct {
BlobsBundle *pb.BlobsBundle
OverrideBuilder bool
// todo: should we convert this to Gwei up front?
Bid primitives.Wei
Bid primitives.Wei
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we so stupid of not moving to Gwei here?

ExecutionRequests *pb.ExecutionRequests
}

// bundleGetter is an interface satisfied by get payload responses that have a blobs bundle.
Expand All @@ -31,13 +32,18 @@ type shouldOverrideBuilderGetter interface {
GetShouldOverrideBuilder() bool
}

type executionRequestsGetter interface {
GetDecodedExecutionRequests() (*pb.ExecutionRequests, error)
}

func NewGetPayloadResponse(msg proto.Message) (*GetPayloadResponse, error) {
r := &GetPayloadResponse{}
bundleGetter, hasBundle := msg.(bundleGetter)
if hasBundle {
r.BlobsBundle = bundleGetter.GetBlobsBundle()
}
bidValueGetter, hasBid := msg.(bidValueGetter)
executionRequestsGetter, hasExecutionRequests := msg.(executionRequestsGetter)
wei := primitives.ZeroWei()
if hasBid {
// The protobuf types that engine api responses unmarshal into store their values in little endian form.
Expand All @@ -56,5 +62,12 @@ func NewGetPayloadResponse(msg proto.Message) (*GetPayloadResponse, error) {
return nil, err
}
r.ExecutionData = ed
if hasExecutionRequests {
requests, err := executionRequestsGetter.GetDecodedExecutionRequests()
if err != nil {
return nil, err
}
r.ExecutionRequests = requests
}
return r, nil
}
10 changes: 10 additions & 0 deletions consensus-types/blocks/setters.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types"
"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"
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v5/runtime/version"
)
Expand Down Expand Up @@ -172,3 +173,12 @@ func (b *SignedBeaconBlock) SetBlobKzgCommitments(c [][]byte) error {
b.block.body.blobKzgCommitments = c
return nil
}

// SetExecutionRequests sets the execution requests in the block.
func (b *SignedBeaconBlock) SetExecutionRequests(er *enginev1.ExecutionRequests) error {
james-prysm marked this conversation as resolved.
Show resolved Hide resolved
if b.version < version.Electra {
return consensus_types.ErrNotSupported("SetExecutionRequests", b.version)
}
b.block.body.executionRequests = er
return nil
}
1 change: 1 addition & 0 deletions consensus-types/interfaces/beacon_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type SignedBeaconBlock interface {
SetProposerIndex(idx primitives.ValidatorIndex)
SetSlot(slot primitives.Slot)
SetSignature(sig []byte)
SetExecutionRequests(er *enginev1.ExecutionRequests) error
Unblind(e ExecutionData) error
}

Expand Down
4 changes: 2 additions & 2 deletions proto/engine/v1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ssz_gen_marshal(
"WithdrawalRequest",
"DepositRequest",
"ConsolidationRequest",
"ExecutionRequests",
"ExecutionRequests",
],
)

Expand All @@ -74,7 +74,7 @@ go_proto_library(
go_library(
name = "go_default_library",
srcs = [
"electra.go",
"electra.go",
"execution_engine.go",
"json_marshal_unmarshal.go",
":ssz_generated_files", # keep
Expand Down
5 changes: 5 additions & 0 deletions proto/engine/v1/electra.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ package enginev1

type ExecutionPayloadElectra = ExecutionPayloadDeneb
type ExecutionPayloadHeaderElectra = ExecutionPayloadHeaderDeneb

func (eee *ExecutionEnvelopeElectra) GetDecodedExecutionRequests() (*ExecutionRequests, error) {
// work on decode here
return nil, nil
}
Loading
Loading