@@ -175,19 +175,27 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, pa
175
175
176
176
// ForkchoiceUpdatedV2 is equivalent to V1 with the addition of withdrawals in the payload attributes.
177
177
func (api * ConsensusAPI ) ForkchoiceUpdatedV2 (update beacon.ForkchoiceStateV1 , payloadAttributes * beacon.PayloadAttributes ) (beacon.ForkChoiceResponse , error ) {
178
- if ! api .eth .BlockChain ().Config ().IsShanghai (payloadAttributes .Timestamp ) {
178
+ if payloadAttributes != nil {
179
+ if err := api .verifyPayloadAttributes (payloadAttributes ); err != nil {
180
+ return beacon .STATUS_INVALID , beacon .InvalidPayloadAttributes .With (err )
181
+ }
182
+ }
183
+ return api .forkchoiceUpdated (update , payloadAttributes )
184
+ }
185
+
186
+ func (api * ConsensusAPI ) verifyPayloadAttributes (attr * beacon.PayloadAttributes ) error {
187
+ if ! api .eth .BlockChain ().Config ().IsShanghai (attr .Timestamp ) {
179
188
// Reject payload attributes with withdrawals before shanghai
180
- if payloadAttributes != nil && payloadAttributes .Withdrawals != nil {
181
- return beacon . STATUS_INVALID , beacon . InvalidPayloadAttributes . With ( errors .New ("withdrawals before shanghai" ) )
189
+ if attr .Withdrawals != nil {
190
+ return errors .New ("withdrawals before shanghai" )
182
191
}
183
192
} else {
184
193
// Reject payload attributes with nil withdrawals after shanghai
185
- if payloadAttributes != nil && payloadAttributes .Withdrawals == nil {
186
- return beacon . STATUS_INVALID , beacon . InvalidPayloadAttributes . With ( errors .New ("missing withdrawals list" ) )
194
+ if attr .Withdrawals == nil {
195
+ return errors .New ("missing withdrawals list" )
187
196
}
188
197
}
189
-
190
- return api .forkchoiceUpdated (update , payloadAttributes )
198
+ return nil
191
199
}
192
200
193
201
func (api * ConsensusAPI ) forkchoiceUpdated (update beacon.ForkchoiceStateV1 , payloadAttributes * beacon.PayloadAttributes ) (beacon.ForkChoiceResponse , error ) {
0 commit comments