Skip to content

M-L05: docs(contracts): document native token deposits#685

Merged
philanton merged 2 commits into
mainfrom
fix/contract-l-05
Apr 15, 2026
Merged

M-L05: docs(contracts): document native token deposits#685
philanton merged 2 commits into
mainfrom
fix/contract-l-05

Conversation

@philanton
Copy link
Copy Markdown
Contributor

@philanton philanton commented Apr 14, 2026

Description

_pullFunds() enforces different funding mechanics for native assets vs ERC20. When token == address(0), it requires msg.value == amount, so the caller must supply native funds even if the logical funding party is def.user. By contrast, the ERC20 path uses IERC20.safeTransferFrom() with the from address’ allowance.
In result, state submissions that require funds movement cannot be enforced by anyone, unless they are willing to pay for it. This asymmetry is not obvious from createChannel() / depositToChannel() and can surprise integrators who assume identical funding mechanics across asset types.

Summary by CodeRabbit

  • Documentation
    • Added comprehensive documentation clarifying deposit mechanics for native ETH versus ERC20 tokens, detailing submission requirements and transaction caller responsibilities across deposit flows.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

This PR adds documentation and inline NOTE comments explaining that ERC20 deposits are pulled via transferFrom (requiring prior allowance and allowing permissionless submission), whereas native ETH deposits require the transaction caller to supply msg.value == amount.

Changes

Cohort / File(s) Summary
Security doc
contracts/SECURITY.md
New section "Native ETH vs ERC20 Deposit Asymmetry" describing how _pullFunds(from, token, amount) differs for address(0) (native ETH) vs ERC20, listing affected flows and integrator guidance.
Protocol docs
protocol-description.md
Added protocol-level explanation of deposit mechanics for ERC20 vs native ETH, including bridging/escrow call sites and submission/value requirements.
Contract comments
contracts/src/ChannelHub.sol
Inserted NOTE comments in createChannel, depositToChannel, and initiateEscrowDeposit documenting that native ETH DEPOSIT intents require the caller to attach msg.value == amount; no executable logic changed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • ihsraham
  • dimast-x

Poem

🐇 I hopped through code and left a note,
Of ERC20 pulls and ETH that must float,
One needs allowance, one needs the fee,
Now integrators know how deposits be,
Cheers from a rabbit, light on its tote!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'M-L05: docs(contracts): document native token deposits' accurately summarizes the main change—adding documentation about native ETH deposit asymmetry mechanics across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/contract-l-05

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
contracts/SECURITY.md (1)

380-387: Optional wording tweak: prefer “native token” over “ETH” for multi-chain precision.

Since this applies on non-Ethereum chains too, consider phrasing as “native token (ETH on Ethereum)” to avoid chain-specific ambiguity in integrator docs.

Also applies to: 400-403

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@contracts/SECURITY.md` around lines 380 - 387, Update the section titled
"Native ETH vs ERC20 Deposit Asymmetry" to use chain-neutral wording: replace
occurrences of "ETH" with "native token" and where helpful add parenthetical
clarification like "(ETH on Ethereum)" so the text reads e.g. "Native token (ETH
on Ethereum) vs ERC20 Deposit Asymmetry" and the bullets refer to "native token"
instead of "Native ETH"; also apply the same replacement to the related lines
referenced (around lines 400-403) so all mentions are consistent across the
section.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@contracts/SECURITY.md`:
- Around line 380-387: Update the section titled "Native ETH vs ERC20 Deposit
Asymmetry" to use chain-neutral wording: replace occurrences of "ETH" with
"native token" and where helpful add parenthetical clarification like "(ETH on
Ethereum)" so the text reads e.g. "Native token (ETH on Ethereum) vs ERC20
Deposit Asymmetry" and the bullets refer to "native token" instead of "Native
ETH"; also apply the same replacement to the related lines referenced (around
lines 400-403) so all mentions are consistent across the section.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a39fa75a-aa4b-4633-8d4f-d80df27b1248

📥 Commits

Reviewing files that changed from the base of the PR and between d29d099 and 30526ac.

📒 Files selected for processing (2)
  • contracts/SECURITY.md
  • contracts/src/ChannelHub.sol
✅ Files skipped from review due to trivial changes (1)
  • contracts/src/ChannelHub.sol

@philanton philanton merged commit 42eaa33 into main Apr 15, 2026
8 checks passed
@philanton philanton deleted the fix/contract-l-05 branch April 15, 2026 09:17
nksazonov added a commit that referenced this pull request Apr 16, 2026
H-H01: fix(contracts): disallow challenge with CLOSE or FIN_MIG intents (#631)

H-M01: fix(contracts/ChannelHub): remove transferred amount check (#636)

fix(contracts/ChannelHub): allow unblocking escrow ops after migration (#637)

M-C01: feat(contracts): add token check between states (#639)

H-L03: fix(contracts/ChannelHub): skip disputed escrow during purge (#640)

M-H04: feat(contracts/ChannelHub): purge during escrow challenge finalization, count both skip and purge (#641)

M-M02: fix(contracts): require zero allocs on close (#643)

M-C02: fix(rpc/core): apply finalize escrow deposit correctly (#644)

H-L02: fix(contracts/ChannelHub): revert on withdrawFromVault failure (#651)

M-H03: fix(clearnode): log correct fields on failure (#647)

M-C03: fix(pkg/core): disallow negative amount transitions (#645)

H-L01: fix(contracts/ChannelHub): add CH address to prevent val addition replay (#650)

M-H06(clearnode): restrict max channel challenge duration (#654)

M-M03(clearnode): revert EscrowLock on insufficient home user balance (#655)

M-M04(clearnode): support default signer even if it is not approved (#656)

M-M05(clearnode): require correct intent on FinalizeEscrowWithdrawal (#657)

M-M09: reject asset decimals exceeding its token's decimals (#659)

M-L01: return correct errors during state advancement validation (#660)

M-L03: limit number of related ids per session key state (#662)

M-I02: normalize input hex addresses (#663)

M-H01: feat(contracts/ChannelHub): restrict to one node (#649)

M-H07: fix(contracts/ChannelHub): emit stored, not arbitrary candidate state (#664)

M-I01: feat(contracts/ChannelHub): remove updateLastState flag (#665)

H-L06: fix(contracts/ChannelHub): remove payable from methods, clarify in create (#666)

H-L09: feat(contracts/ChannelEngine): add non-home migration version check (#669)

YNU-839: fix blockchain listener lifecycle (#658)

M-H09: use channel signer for all channel state node sigs (#667)

H-L07: fix(contracts/ChannelHub): restrict createChannel to non-existing channels (#668)

H-I02: docs(contracts): add a note that rebasing tokens are not supported (#670)

H-I03: fix(contracts/ChannelHub): use CIE pattern in depositToHub (#671)

M-H11: revert empty signatures on quorum verification (#672)

M-H11: reject issuance of receiver state during escrow ops (#674)

H-I01: docs(contracts): note that fee-on-transfer tokens are not supported (#675)

M-L04: docs: mention liquidity monitoring (#677)

fix(contracts/ChannelHub): fix initialize escrow deposit dos (#679)

M-H08: enforce strict transition ordering after MutualLock and EscrowLock (#680)

fix: run forge fmt (#681)

M-L05: docs(contracts): document native token deposits (#685)

fix(clearnode): resolve a set of audit findings (#686)

M-H13: feat(contract): add validateChallengeSignature, revert in SK validator (#688)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants