htlcswitch: skip checking replays for reforwarded packets

We now rely on the forwarding package's state to decide whether a given
packet is a reforwarding or not. If we know it's a reforwarding packet,
there's no need to check for replays in the `sharedHashes` bucket, which
behaves the same as if we are querying the `batchReplayBkt`.
This commit is contained in:
yyforyongyu
2025-06-11 12:16:09 +08:00
committed by Olaoluwa Osuntokun
parent 2b3c04ccaa
commit cb009119c4
3 changed files with 19 additions and 15 deletions

View File

@@ -745,7 +745,8 @@ func (r *DecodeHopIteratorResponse) Result() (Iterator, lnwire.FailCode) {
// the presented readers and rhashes *NEVER* deviate across invocations for the
// same id.
func (p *OnionProcessor) DecodeHopIterators(id []byte,
reqs []DecodeHopIteratorRequest) ([]DecodeHopIteratorResponse, error) {
reqs []DecodeHopIteratorRequest,
reforward bool) ([]DecodeHopIteratorResponse, error) {
var (
batchSize = len(reqs)
@@ -864,11 +865,12 @@ func (p *OnionProcessor) DecodeHopIterators(id []byte,
continue
}
// If this index is contained in the replay set, mark it with a
// temporary channel failure error code. We infer that the
// offending error was due to a replayed packet because this
// index was found in the replay set.
if replays.Contains(uint16(i)) {
// If this index is contained in the replay set, and it is not a
// reforwarding on startup, mark it with a permanent channel
// failure error code. We infer that the offending error was due
// to a replayed packet because this index was found in the
// replay set.
if !reforward && replays.Contains(uint16(i)) {
log.Errorf("unable to process onion packet: %v",
sphinx.ErrReplayedPacket)