Skip to content

Commit df52967

Browse files
authored
eth/catalyst: fix panic in TestWithdrawals (#26563)
Fixes a regression introduced in #26549
1 parent 90f15a0 commit df52967

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

eth/catalyst/api.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
177177
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) {
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

193201
func (api *ConsensusAPI) forkchoiceUpdated(update beacon.ForkchoiceStateV1, payloadAttributes *beacon.PayloadAttributes) (beacon.ForkChoiceResponse, error) {

0 commit comments

Comments
 (0)