Skip to content

feat(cketh): scan and detect ETH deposits - #11508

Draft
gregorydemay wants to merge 2 commits into
gdemay/DEFI-2931-deposit-eth-arms-pairfrom
gdemay/DEFI-2931-scan-eth-balances
Draft

feat(cketh): scan and detect ETH deposits#11508
gregorydemay wants to merge 2 commits into
gdemay/DEFI-2931-deposit-eth-arms-pairfrom
gdemay/DEFI-2931-scan-eth-balances

Conversation

@gregorydemay

@gregorydemay gregorydemay commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Stacked on #11499. Third step of the deposit_eth flow per the spec: an armed (account, ETH) pair is now actually scanned and, when funded with at least 0.005 ETH, detected and queued for sweeping — deposit_eth reports AwaitingSweep.

  • A dedicated 78-byte deployless batcher program reads ETH balances with the BALANCE opcode and returns them in the same flat layout as the ERC-20 batcher, so the decoder is shared. The validated ERC-20 program is byte-identical — chosen over extending it with a zero-token-slot branch, which would have re-assembled the whole program. Validated against a live anvil node, including agreement with the node's own view of every balance.
  • The scan tick partitions its due pairs by asset and sends both batches pinned to the same latest block, under the same timer guard.
  • Queued ETH entries are not batched into sweeps yet: the sweepEthBatch lane comes in a follow-up (behind the delegation-record work per the spec's delivery order), which is also why the sweep-batching todo! became an explicit skip. The spec's phase-2 wording (zero address in the token slot) needs a small amendment in docs(cketh): specify ETH deposits on the shared address and sweeper delegate rotation #11491 to record the separate-program choice.

🤖 Generated with Claude Code

https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9

gregorydemay and others added 2 commits September 9, 2026 08:51
The native-ETH sibling of the ERC-20 balance batcher: a 78-byte
create-style eth_call program that reads [n][holder x n] appended after
its code and returns each holder's ETH balance via the BALANCE opcode,
in the same flat n x 32 layout so the decoder is shared. No sub-calls,
so unlike the ERC-20 batcher it has no revert path. Validated against a
live anvil node, including agreement with the node's own view of every
balance. The ERC-20 program is untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9
The balance-scan tick now partitions its due pairs by asset and sends
two batched eth_calls pinned to the same latest block: the untouched
ERC-20 batcher first, then the new ETH batcher. An ETH balance at or
above the 0.005 ETH minimum is detected and queued for sweeping exactly
like a token balance, so deposit_eth reports AwaitingSweep. Queued ETH
entries are not batched into sweeps yet: the sweepEthBatch lane comes in
a follow-up, which is also why the reachable-from-now todo in the sweep
batching becomes an explicit skip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9
@gregorydemay
gregorydemay added this pull request to stack #11500 September 9, 2026 07:04
@gregorydemay gregorydemay changed the title gdemay/DEFI 2931 scan eth balances feat(cketh): scan and detect ETH deposits Sep 9, 2026
@gregorydemay
gregorydemay requested a balanced review from Copilot September 9, 2026 07:04
@github-actions github-actions Bot added the feat label Sep 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Low-level EVM bytecode and mixed-asset deposit processing require final human review.

Pull request overview

Adds native ETH deposit scanning and queues qualifying deposits for future sweeping.

Changes:

  • Adds a deployless EVM batcher for ETH balances.
  • Splits ETH and ERC-20 scans while pinning them to the same block.
  • Detects qualifying ETH deposits but excludes them from current sweep batches.
File summaries
File Description
rs/ethereum/cketh/test_utils/src/ckerc20.rs Supports mocked mixed-asset scans.
rs/ethereum/cketh/test_utils/src/anvil.rs Adds an ETH transfer helper.
rs/ethereum/cketh/minter/tests/deposit_from_cex.rs Validates the ETH batcher against Anvil.
rs/ethereum/cketh/minter/tests/ckerc20.rs Tests ETH detection and mixed scans.
rs/ethereum/cketh/minter/src/state/automatic_deposits/tests.rs Tests ETH targets and sweep exclusion.
rs/ethereum/cketh/minter/src/state/automatic_deposits/mod.rs Enables ETH targets and skips ETH sweeping.
rs/ethereum/cketh/minter/src/balance_scan/tests.rs Adapts ERC-20 scan tests.
rs/ethereum/cketh/minter/src/balance_scan/mod.rs Implements partitioned ETH/ERC-20 scanning.
rs/ethereum/cketh/minter/src/balance_scan/batcher/tests.rs Verifies ETH bytecode and encoding.
rs/ethereum/cketh/minter/src/balance_scan/batcher/mod.rs Implements the ETH balance batcher.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants