-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Execution API Electra: requests as a sidecar #14492
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
Changes from 34 commits
3172789
806d783
e5b8bd3
5976923
426f664
3b0c6e2
c215ba9
ed07b75
7517ac3
069f8c8
56dc32a
e7dfa24
e985dd8
015aeed
81e4648
ef8281e
7767410
0e7a058
575b528
f854fdf
4a44864
e533241
539a633
2cec3a4
12f0a06
ff3170a
9dae721
8362871
43e01c4
f7ef1f3
b41b707
7438ba2
040e48c
c24825a
9cc52a3
ad56480
5f95c3d
8ee48ca
6c8baf5
0580bb5
bea42f4
2ffb01b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,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) | ||
|
|
@@ -125,8 +125,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() | ||
|
|
@@ -163,9 +163,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 { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
|
|
@@ -259,13 +270,16 @@ 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().DenebForkEpoch { | ||
| switch { | ||
james-prysm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| case pe >= params.BeaconConfig().ElectraForkEpoch: | ||
| return GetPayloadMethodV4, &pb.ExecutionBundleElectra{} | ||
| case pe == params.BeaconConfig().DenebForkEpoch: | ||
| return GetPayloadMethodV3, &pb.ExecutionPayloadDenebWithValueAndBlobsBundle{} | ||
| } | ||
| if pe >= params.BeaconConfig().CapellaForkEpoch { | ||
| case pe == params.BeaconConfig().CapellaForkEpoch: | ||
| return GetPayloadMethodV2, &pb.ExecutionPayloadCapellaWithValue{} | ||
| default: | ||
| return GetPayloadMethod, &pb.ExecutionPayload{} | ||
| } | ||
| return GetPayloadMethod, &pb.ExecutionPayload{} | ||
| } | ||
|
|
||
| // GetPayload calls the engine_getPayloadVX method via JSON-RPC. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.