@@ -175,19 +175,27 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, pa
175175
176176// ForkchoiceUpdatedV2 is equivalent to V1 with the addition of withdrawals in the payload attributes.
177177func (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 ) {
179188 // 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" )
182191 }
183192 } else {
184193 // 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" )
187196 }
188197 }
189-
190- return api .forkchoiceUpdated (update , payloadAttributes )
198+ return nil
191199}
192200
193201func (api * ConsensusAPI ) forkchoiceUpdated (update beacon.ForkchoiceStateV1 , payloadAttributes * beacon.PayloadAttributes ) (beacon.ForkChoiceResponse , error ) {
0 commit comments