MF-L06: fix(contracts): clear stale challengeExpireAt on cooperative escrow finalization#754
Conversation
…inalization Regression tests added for both escrow deposit and escrow withdrawal.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
contracts/test/ChannelHub_units/ChannelHub_finalizeEscrowDeposit.t.sol (1)
9-9: 💤 Low valueOptional: Consider removing unused import.
The
EscrowDepositEngineimport doesn't appear to be referenced in the test code. While this doesn't affect functionality, removing unused imports can improve code clarity.♻️ Optional cleanup
-import {EscrowDepositEngine} from "../../src/EscrowDepositEngine.sol";🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@contracts/test/ChannelHub_units/ChannelHub_finalizeEscrowDeposit.t.sol` at line 9, The import of EscrowDepositEngine is unused in the test (EscrowDepositEngine) — remove the unused import statement from ChannelHub_finalizeEscrowDeposit.t.sol to clean up the file; locate the line importing EscrowDepositEngine and delete it so the test compiles and reads without the unnecessary symbol.contracts/test/ChannelHub_units/ChannelHub_finalizeEscrowWithdrawal.t.sol (1)
9-9: 💤 Low valueOptional: Consider removing unused import.
The
EscrowWithdrawalEngineimport doesn't appear to be referenced in the test code. While this doesn't affect functionality, removing unused imports can improve code clarity.♻️ Optional cleanup
-import {EscrowWithdrawalEngine} from "../../src/EscrowWithdrawalEngine.sol";🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@contracts/test/ChannelHub_units/ChannelHub_finalizeEscrowWithdrawal.t.sol` at line 9, Remove the unused import of EscrowWithdrawalEngine from the test file by deleting the import line that references EscrowWithdrawalEngine; the symbol EscrowWithdrawalEngine is not referenced anywhere in ChannelHub_finalizeEscrowWithdrawal tests, so removing that unused import cleans up the file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@contracts/test/ChannelHub_units/ChannelHub_finalizeEscrowDeposit.t.sol`:
- Line 9: The import of EscrowDepositEngine is unused in the test
(EscrowDepositEngine) — remove the unused import statement from
ChannelHub_finalizeEscrowDeposit.t.sol to clean up the file; locate the line
importing EscrowDepositEngine and delete it so the test compiles and reads
without the unnecessary symbol.
In `@contracts/test/ChannelHub_units/ChannelHub_finalizeEscrowWithdrawal.t.sol`:
- Line 9: Remove the unused import of EscrowWithdrawalEngine from the test file
by deleting the import line that references EscrowWithdrawalEngine; the symbol
EscrowWithdrawalEngine is not referenced anywhere in
ChannelHub_finalizeEscrowWithdrawal tests, so removing that unused import cleans
up the file.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c0514c21-8991-4afc-8065-94093bc7369c
📒 Files selected for processing (3)
contracts/src/ChannelHub.solcontracts/test/ChannelHub_units/ChannelHub_finalizeEscrowDeposit.t.solcontracts/test/ChannelHub_units/ChannelHub_finalizeEscrowWithdrawal.t.sol
- MF-L01: fix(contracts/ChannelHub): cap ERC20 transfer returndata copy to 32 bytes (#726) - MF-H01: fix(nitronode): paginate get_last_key_states endpoints (#724) - MF-I01-I02: fix(contracts): address security audit findings I-01 and I-02 (#728) - MF-C01: rpc: cap inbound WebSocket frame size and rate-limit per connection (#723) - MF-L02: docs(protocol): qualify enforcement guarantee for intent-specific execution paths (#737) - MF-L02-I03-I04_I05: fix(contracts): add more Node trust assumptions and requirements (#738) - MF-M01: backfill state user_sig from on-chain events (#731) - MF-M02: fix(rpc): release Serve wait group on processSink overflow (#732) - Fix SDK acknowledgement before home channel creation (#734) - MF-I06: fix(nitronode): gate escrow transitions on home channel onchain materialization (#730) - MF-M05: fix(nitronode): enforce TLS by default for Postgres (#733) - MF-M07: Unblock receiver states after finalized escrow operations (#735) - MF-M04: feat: provide tooling for and enhance docs on ValidatorRegistered event (#744) - MF-L04: fix(contracts): reject redundant native value (#741) - MF-H02: bind session key registration to a single owner per kind (#739) - MF-I07: fix(contracts): enforce max challenge duration (#752) - MF-M08: fix(rpc): replace Origin label with application_id on connection gauge (#745) - MF-C02: fix(core): add ChannelStatusClosing to gate post-finalize state transitions (#746) - MF-L06: fix(contracts): clear stale challengeExpireAt on cooperative escrow finalization (#754) - MF-I08: docs: document ChannelClosed event orientation ambiguity during abandoned migration (#755) - MF-M09: fix(nitronode): auto-challenge home channel on withheld escrow finalize (#753) - MF-L09: fix(nitronode): validate parsed app session nonce (#751) - MF-L05: docs(contracts): document informational events not guaranteed to emit (#756) - MF-L08: fix(nitronode/api): default get_last_key_states to active-only with include_inactive opt-in (#749) - MF-L10: fix: emit escrowIds array in EscrowDepositsPurged event and handle it in Nitronode (#757)
Problem
_applyEscrowDepositEffects()and_applyEscrowWithdrawalEffects()only updatedmeta.challengeExpireAtwheneffects.newChallengeExpiry > 0. Since cooperative finalization leavesnewChallengeExpiryat its zero default, this condition was never true — meaning a prior non-zerochallengeExpireAtset during a challenge was silently left in storage after finalization.The result: a cooperatively finalized escrow (transitioning from
DISPUTEDtoFINALIZED) would still report a non-zerochallengeExpirythroughgetEscrowDepositData()/getEscrowWithdrawalData(), misleading indexers, SDKs, and UIs.The unilateral timeout paths cleared
challengeExpireAtexplicitly, so only the cooperative path fromDISPUTEDwas affected.Fix
Replace the
> 0guard with a!=comparison in both apply helpers, mirroring the pattern already used in the channel apply path:Tests
Regression tests added to:
test/ChannelHub_units/ChannelHub_finalizeEscrowDeposit.t.sol—test_cooperativeFinalize_fromDISPUTED_clearsChallengeExpirytest/ChannelHub_units/ChannelHub_finalizeEscrowWithdrawal.t.sol—test_cooperativeFinalize_fromDISPUTED_clearsChallengeExpiryEach test: initiates an escrow → challenges it (asserting non-zero
challengeExpireAt) → cooperatively finalizes before challenge expires → assertschallengeExpireAt == 0and statusFINALIZED.Summary by CodeRabbit
Bug Fixes
Tests