@@ -50,6 +50,7 @@ const (
50
50
NewPayloadMethod = "engine_newPayloadV1"
51
51
// NewPayloadMethodV2 v2 request string for JSON-RPC.
52
52
NewPayloadMethodV2 = "engine_newPayloadV2"
53
+ NewPayloadMethodV3 = "engine_newPayloadV3"
53
54
// ForkchoiceUpdatedMethod v1 request string for JSON-RPC.
54
55
ForkchoiceUpdatedMethod = "engine_forkchoiceUpdatedV1"
55
56
// ForkchoiceUpdatedMethodV2 v2 request string for JSON-RPC.
@@ -58,6 +59,7 @@ const (
58
59
GetPayloadMethod = "engine_getPayloadV1"
59
60
// GetPayloadMethodV2 v2 request string for JSON-RPC.
60
61
GetPayloadMethodV2 = "engine_getPayloadV2"
62
+ GetPayloadMethodV3 = "engine_getPayloadV3"
61
63
// ExchangeTransitionConfigurationMethod v1 request string for JSON-RPC.
62
64
ExchangeTransitionConfigurationMethod = "engine_exchangeTransitionConfigurationV1"
63
65
// ExecutionBlockByHashMethod request string for JSON-RPC.
@@ -96,11 +98,11 @@ type ExecutionPayloadReconstructor interface {
96
98
// EngineCaller defines a client that can interact with an Ethereum
97
99
// execution node's engine service via JSON-RPC.
98
100
type EngineCaller interface {
99
- NewPayload (ctx context.Context , payload interfaces.ExecutionData ) ([]byte , error )
101
+ NewPayload (ctx context.Context , payload interfaces.ExecutionData , versionedHashes [][ 32 ] byte ) ([]byte , error )
100
102
ForkchoiceUpdated (
101
103
ctx context.Context , state * pb.ForkchoiceState , attrs payloadattribute.Attributer ,
102
104
) (* pb.PayloadIDBytes , []byte , error )
103
- GetPayload (ctx context.Context , payloadId [8 ]byte , slot primitives.Slot ) (interfaces.ExecutionData , error )
105
+ GetPayload (ctx context.Context , payloadId [8 ]byte , slot primitives.Slot ) (interfaces.ExecutionData , * pb. BlobsBundle , error )
104
106
ExchangeTransitionConfiguration (
105
107
ctx context.Context , cfg * pb.TransitionConfiguration ,
106
108
) error
@@ -111,7 +113,7 @@ type EngineCaller interface {
111
113
var EmptyBlockHash = errors .New ("Block hash is empty 0x0000..." )
112
114
113
115
// NewPayload calls the engine_newPayloadVX method via JSON-RPC.
114
- func (s * Service ) NewPayload (ctx context.Context , payload interfaces.ExecutionData ) ([]byte , error ) {
116
+ func (s * Service ) NewPayload (ctx context.Context , payload interfaces.ExecutionData , versionedHashes [][ 32 ] byte ) ([]byte , error ) {
115
117
ctx , span := trace .StartSpan (ctx , "powchain.engine-api-client.NewPayload" )
116
118
defer span .End ()
117
119
start := time .Now ()
@@ -143,6 +145,15 @@ func (s *Service) NewPayload(ctx context.Context, payload interfaces.ExecutionDa
143
145
if err != nil {
144
146
return nil , handleRPCError (err )
145
147
}
148
+ case * pb.ExecutionPayloadDeneb :
149
+ payloadPb , ok := payload .Proto ().(* pb.ExecutionPayloadDeneb )
150
+ if ! ok {
151
+ return nil , errors .New ("execution data must be a Deneb execution payload" )
152
+ }
153
+ err := s .rpcClient .CallContext (ctx , result , NewPayloadMethodV3 , payloadPb , versionedHashes )
154
+ if err != nil {
155
+ return nil , handleRPCError (err )
156
+ }
146
157
default :
147
158
return nil , errors .New ("unknown execution data type" )
148
159
}
@@ -190,7 +201,7 @@ func (s *Service) ForkchoiceUpdated(
190
201
if err != nil {
191
202
return nil , nil , handleRPCError (err )
192
203
}
193
- case version .Capella :
204
+ case version .Capella , version . Deneb :
194
205
a , err := attrs .PbV2 ()
195
206
if err != nil {
196
207
return nil , nil , err
@@ -220,7 +231,8 @@ func (s *Service) ForkchoiceUpdated(
220
231
}
221
232
222
233
// GetPayload calls the engine_getPayloadVX method via JSON-RPC.
223
- func (s * Service ) GetPayload (ctx context.Context , payloadId [8 ]byte , slot primitives.Slot ) (interfaces.ExecutionData , error ) {
234
+ // It returns the execution data as well as the blobs bundle.
235
+ func (s * Service ) GetPayload (ctx context.Context , payloadId [8 ]byte , slot primitives.Slot ) (interfaces.ExecutionData , * pb.BlobsBundle , error ) {
224
236
ctx , span := trace .StartSpan (ctx , "powchain.engine-api-client.GetPayload" )
225
237
defer span .End ()
226
238
start := time .Now ()
@@ -232,23 +244,44 @@ func (s *Service) GetPayload(ctx context.Context, payloadId [8]byte, slot primit
232
244
ctx , cancel := context .WithDeadline (ctx , d )
233
245
defer cancel ()
234
246
247
+ if slots .ToEpoch (slot ) >= params .BeaconConfig ().DenebForkEpoch {
248
+ result := & pb.ExecutionPayloadDenebWithValueAndBlobsBundle {}
249
+ err := s .rpcClient .CallContext (ctx , result , GetPayloadMethodV3 , pb .PayloadIDBytes (payloadId ))
250
+ if err != nil {
251
+ return nil , nil , handleRPCError (err )
252
+ }
253
+ v := big .NewInt (0 ).SetBytes (bytesutil .ReverseByteOrder (result .Value ))
254
+ ed , err := blocks .WrappedExecutionPayloadDeneb (result .Payload , math .WeiToGwei (v ))
255
+ if err != nil {
256
+ return nil , nil , err
257
+ }
258
+ return ed , result .BlobsBundle , nil
259
+ }
260
+
235
261
if slots .ToEpoch (slot ) >= params .BeaconConfig ().CapellaForkEpoch {
236
262
result := & pb.ExecutionPayloadCapellaWithValue {}
237
263
err := s .rpcClient .CallContext (ctx , result , GetPayloadMethodV2 , pb .PayloadIDBytes (payloadId ))
238
264
if err != nil {
239
- return nil , handleRPCError (err )
265
+ return nil , nil , handleRPCError (err )
240
266
}
241
-
242
267
v := big .NewInt (0 ).SetBytes (bytesutil .ReverseByteOrder (result .Value ))
243
- return blocks .WrappedExecutionPayloadCapella (result .Payload , math .WeiToGwei (v ))
268
+ ed , err := blocks .WrappedExecutionPayloadCapella (result .Payload , math .WeiToGwei (v ))
269
+ if err != nil {
270
+ return nil , nil , err
271
+ }
272
+ return ed , nil , nil
244
273
}
245
274
246
275
result := & pb.ExecutionPayload {}
247
276
err := s .rpcClient .CallContext (ctx , result , GetPayloadMethod , pb .PayloadIDBytes (payloadId ))
248
277
if err != nil {
249
- return nil , handleRPCError (err )
278
+ return nil , nil , handleRPCError (err )
250
279
}
251
- return blocks .WrappedExecutionPayload (result )
280
+ ed , err := blocks .WrappedExecutionPayload (result )
281
+ if err != nil {
282
+ return nil , nil , err
283
+ }
284
+ return ed , nil , nil
252
285
}
253
286
254
287
// ExchangeTransitionConfiguration calls the engine_exchangeTransitionConfigurationV1 method via JSON-RPC.
@@ -684,7 +717,8 @@ func fullPayloadFromExecutionBlock(
684
717
txs [i ] = txBin
685
718
}
686
719
687
- if block .Version == version .Bellatrix {
720
+ switch block .Version {
721
+ case version .Bellatrix :
688
722
return blocks .WrappedExecutionPayload (& pb.ExecutionPayload {
689
723
ParentHash : header .ParentHash (),
690
724
FeeRecipient : header .FeeRecipient (),
@@ -701,24 +735,51 @@ func fullPayloadFromExecutionBlock(
701
735
BlockHash : blockHash [:],
702
736
Transactions : txs ,
703
737
})
738
+ case version .Capella :
739
+ return blocks .WrappedExecutionPayloadCapella (& pb.ExecutionPayloadCapella {
740
+ ParentHash : header .ParentHash (),
741
+ FeeRecipient : header .FeeRecipient (),
742
+ StateRoot : header .StateRoot (),
743
+ ReceiptsRoot : header .ReceiptsRoot (),
744
+ LogsBloom : header .LogsBloom (),
745
+ PrevRandao : header .PrevRandao (),
746
+ BlockNumber : header .BlockNumber (),
747
+ GasLimit : header .GasLimit (),
748
+ GasUsed : header .GasUsed (),
749
+ Timestamp : header .Timestamp (),
750
+ ExtraData : header .ExtraData (),
751
+ BaseFeePerGas : header .BaseFeePerGas (),
752
+ BlockHash : blockHash [:],
753
+ Transactions : txs ,
754
+ Withdrawals : block .Withdrawals ,
755
+ }, 0 ) // We can't get the block value and don't care about the block value for this instance
756
+ case version .Deneb :
757
+ edg , err := header .ExcessDataGas ()
758
+ if err != nil {
759
+ return nil , errors .Wrap (err , "unable to extract ExcessDataGas attribute from excution payload header" )
760
+ }
761
+ return blocks .WrappedExecutionPayloadDeneb (
762
+ & pb.ExecutionPayloadDeneb {
763
+ ParentHash : header .ParentHash (),
764
+ FeeRecipient : header .FeeRecipient (),
765
+ StateRoot : header .StateRoot (),
766
+ ReceiptsRoot : header .ReceiptsRoot (),
767
+ LogsBloom : header .LogsBloom (),
768
+ PrevRandao : header .PrevRandao (),
769
+ BlockNumber : header .BlockNumber (),
770
+ GasLimit : header .GasLimit (),
771
+ GasUsed : header .GasUsed (),
772
+ Timestamp : header .Timestamp (),
773
+ ExtraData : header .ExtraData (),
774
+ BaseFeePerGas : header .BaseFeePerGas (),
775
+ BlockHash : blockHash [:],
776
+ Transactions : txs ,
777
+ Withdrawals : block .Withdrawals ,
778
+ ExcessDataGas : edg ,
779
+ }, 0 ) // We can't get the block value and don't care about the block value for this instance
780
+ default :
781
+ return nil , fmt .Errorf ("unknown execution block version %d" , block .Version )
704
782
}
705
- return blocks .WrappedExecutionPayloadCapella (& pb.ExecutionPayloadCapella {
706
- ParentHash : header .ParentHash (),
707
- FeeRecipient : header .FeeRecipient (),
708
- StateRoot : header .StateRoot (),
709
- ReceiptsRoot : header .ReceiptsRoot (),
710
- LogsBloom : header .LogsBloom (),
711
- PrevRandao : header .PrevRandao (),
712
- BlockNumber : header .BlockNumber (),
713
- GasLimit : header .GasLimit (),
714
- GasUsed : header .GasUsed (),
715
- Timestamp : header .Timestamp (),
716
- ExtraData : header .ExtraData (),
717
- BaseFeePerGas : header .BaseFeePerGas (),
718
- BlockHash : blockHash [:],
719
- Transactions : txs ,
720
- Withdrawals : block .Withdrawals ,
721
- }, 0 ) // We can't get the block value and don't care about the block value for this instance
722
783
}
723
784
724
785
// Handles errors received from the RPC server according to the specification.
0 commit comments