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 all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Updating to this release is recommended at your convenience.
- GetBeaconStateV2: add Electra case.
- Implement [consensus-specs/3875](https://github.com/ethereum/consensus-specs/pull/3875).
- Tests to ensure sepolia config matches the official upstream yaml.
- `engine_newPayloadV4`,`engine_getPayloadV4` used for electra payload communication with execution client. [pr](https://github.com/prysmaticlabs/prysm/pull/14492)
- HTTP endpoint for PublishBlobs.
- GetBlockV2, GetBlindedBlock, ProduceBlockV2, ProduceBlockV3: add Electra case.
- Add Electra support and tests for light client functions.
Expand Down
18 changes: 13 additions & 5 deletions beacon-chain/blockchain/execution_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,25 @@ func (s *Service) notifyNewPayload(ctx context.Context, preStateVersion int,
}

var lastValidHash []byte
var parentRoot *common.Hash
var versionedHashes []common.Hash
var requests *enginev1.ExecutionRequests
if blk.Version() >= version.Deneb {
var versionedHashes []common.Hash
versionedHashes, err = kzgCommitmentsToVersionedHashes(blk.Block().Body())
if err != nil {
return false, errors.Wrap(err, "could not get versioned hashes to feed the engine")
}
pr := common.Hash(blk.Block().ParentRoot())
lastValidHash, err = s.cfg.ExecutionEngineCaller.NewPayload(ctx, payload, versionedHashes, &pr)
} else {
lastValidHash, err = s.cfg.ExecutionEngineCaller.NewPayload(ctx, payload, []common.Hash{}, &common.Hash{} /*empty version hashes and root before Deneb*/)
prh := common.Hash(blk.Block().ParentRoot())
parentRoot = &prh
}
if blk.Version() >= version.Electra {
requests, err = blk.Block().Body().ExecutionRequests()
if err != nil {
return false, errors.Wrap(err, "could not get execution requests")
}
}
lastValidHash, err = s.cfg.ExecutionEngineCaller.NewPayload(ctx, payload, versionedHashes, parentRoot, requests)

switch {
case err == nil:
newPayloadValidNodeCount.Inc()
Expand Down
26 changes: 20 additions & 6 deletions beacon-chain/execution/engine_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type PayloadReconstructor interface {
// EngineCaller defines a client that can interact with an Ethereum
// execution node's engine service via JSON-RPC.
type EngineCaller interface {
NewPayload(ctx context.Context, payload interfaces.ExecutionData, versionedHashes []common.Hash, parentBlockRoot *common.Hash) ([]byte, error)
NewPayload(ctx context.Context, payload interfaces.ExecutionData, versionedHashes []common.Hash, parentBlockRoot *common.Hash, executionRequests *pb.ExecutionRequests) ([]byte, error)
ForkchoiceUpdated(
ctx context.Context, state *pb.ForkchoiceState, attrs payloadattribute.Attributer,
) (*pb.PayloadIDBytes, []byte, error)
Expand All @@ -119,8 +119,8 @@ type EngineCaller interface {

var ErrEmptyBlockHash = errors.New("Block hash is empty 0x0000...")

// NewPayload calls the engine_newPayloadVX method via JSON-RPC.
func (s *Service) NewPayload(ctx context.Context, payload interfaces.ExecutionData, versionedHashes []common.Hash, parentBlockRoot *common.Hash) ([]byte, error) {
// NewPayload request calls the engine_newPayloadVX method via JSON-RPC.
func (s *Service) NewPayload(ctx context.Context, payload interfaces.ExecutionData, versionedHashes []common.Hash, parentBlockRoot *common.Hash, executionRequests *pb.ExecutionRequests) ([]byte, error) {
ctx, span := trace.StartSpan(ctx, "powchain.engine-api-client.NewPayload")
defer span.End()
start := time.Now()
Expand Down Expand Up @@ -157,9 +157,20 @@ func (s *Service) NewPayload(ctx context.Context, payload interfaces.ExecutionDa
if !ok {
return nil, errors.New("execution data must be a Deneb execution payload")
}
err := s.rpcClient.CallContext(ctx, result, NewPayloadMethodV3, payloadPb, versionedHashes, parentBlockRoot)
if err != nil {
return nil, handleRPCError(err)
if executionRequests == nil {
Copy link
Member

Choose a reason for hiding this comment

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

This feels prone to bugs and hard to test against . Checking payload's version may be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah , the caller checks the version on the block, but the payload doesn't include the version , I can pass the block version into this function if that makes it safer

err := s.rpcClient.CallContext(ctx, result, NewPayloadMethodV3, payloadPb, versionedHashes, parentBlockRoot)
if err != nil {
return nil, handleRPCError(err)
}
} else {
flattenedRequests, err := pb.EncodeExecutionRequests(executionRequests)
if err != nil {
return nil, errors.Wrap(err, "failed to encode execution requests")
}
err = s.rpcClient.CallContext(ctx, result, NewPayloadMethodV4, payloadPb, versionedHashes, parentBlockRoot, flattenedRequests)
if err != nil {
return nil, handleRPCError(err)
}
}
default:
return nil, errors.New("unknown execution data type")
Expand Down Expand Up @@ -253,6 +264,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.ExecutionBundleElectra{}
}
if pe >= params.BeaconConfig().DenebForkEpoch {
return GetPayloadMethodV3, &pb.ExecutionPayloadDenebWithValueAndBlobsBundle{}
}
Expand Down
Loading
Loading