diff --git a/consensus/merge/merge.go b/consensus/merge/merge.go index bab6541532b..bf7af5c000f 100644 --- a/consensus/merge/merge.go +++ b/consensus/merge/merge.go @@ -189,9 +189,23 @@ func (s *Merge) Finalize(config *chain.Config, header *types.Header, state *stat if config.IsPrague(header.Time) { rs = make(types.FlatRequests, 0) allLogs := make(types.Logs, 0) + skipEvaluation := false + for _, rec := range receipts { + // VERY UGLY HACK: We need to skip evaluation if we have a nil receipt + + // Check for nil receipt to handle a special corner case: + // This scenario occurs when a transaction is part of an incomplete or partially executed block, + // causing some transaction receipts to be unavailable (nil). In such cases, + // evaluation must be skipped to prevent accessing logs from an invalid receipt. + if rec == nil { + skipEvaluation = true + logger.Info("nil receipt found in block receipts, skipping evaluation of receiptsHash") + break + } allLogs = append(allLogs, rec.Logs...) } + depositReqs, err := misc.ParseDepositLogs(allLogs, config.DepositContract) if err != nil { return nil, nil, nil, fmt.Errorf("error: could not parse requests logs: %v", err) @@ -207,7 +221,7 @@ func (s *Merge) Finalize(config *chain.Config, header *types.Header, state *stat if consolidations != nil { rs = append(rs, *consolidations) } - if header.RequestsHash != nil { + if header.RequestsHash != nil && !skipEvaluation { rh := rs.Hash() if *header.RequestsHash != *rh { return nil, nil, nil, fmt.Errorf("error: invalid requests root hash in header, expected: %v, got :%v", header.RequestsHash, rh)