From 8ad760e10c3e1dea83ead6d5db4b09d13e308ebf Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Jan 2026 20:04:03 +0100 Subject: [PATCH] fix(settlement): accumulate validator notes across rate change segments Previously, when settling a rail with multiple rate changes in the queue, only the final segment's note was retained. Now notes from all segments are accumulated with "; " separators, following the pattern used in checkAndFinalizeTerminatedRail. Only non-empty notes are added to the accumulator. Updated test to verify the accumulated notes behavior. Fixes #268 Co-Authored-By: Claude Opus 4.5 --- src/FilecoinPayV1.sol | 10 +++++++++- test/RailSettlement.t.sol | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/FilecoinPayV1.sol b/src/FilecoinPayV1.sol index 0d1dc78..201935a 100644 --- a/src/FilecoinPayV1.sol +++ b/src/FilecoinPayV1.sol @@ -1361,7 +1361,15 @@ contract FilecoinPayV1 is ReentrancyGuard { // Add the gross settled amount to our running total totalGrossSettled += segmentGrossSettled; - note = validationNote; + + // Accumulate validation notes from each segment + if (bytes(validationNote).length > 0) { + if (bytes(note).length > 0) { + note = string.concat(note, "; ", validationNote); + } else { + note = validationNote; + } + } // If validator partially settled the segment, exit early if (rail.settledUpTo < segmentEndBoundary) { diff --git a/test/RailSettlement.t.sol b/test/RailSettlement.t.sol index d2acf29..a7e0e36 100644 --- a/test/RailSettlement.t.sol +++ b/test/RailSettlement.t.sol @@ -226,8 +226,13 @@ contract RailSettlementTest is Test, BaseTestHelper { RailSettlementHelpers.SettlementResult memory result = settlementHelper.settleRailAndVerify(railId, block.number, expectedAmount, block.number); - // Verify validator note - assertEq(result.note, "Standard approved payment", "Validator note should match"); + // Verify validator notes are accumulated from all 9 segments + // (8 rate changes in the queue + 1 final segment) + string memory expectedNote = "Standard approved payment"; + for (uint256 i = 1; i < 9; i++) { + expectedNote = string.concat(expectedNote, "; Standard approved payment"); + } + assertEq(result.note, expectedNote, "Validator notes should be accumulated"); } function testValidationWithReducedAmount() public {