Skip to content

fix(cketh): derive the balance-scan batch size from the EIP-3860 initcode limit - #11489

Merged
gregorydemay merged 4 commits into
masterfrom
gdemay/DEFI-2996-balance-scan-initcode-limit
Sep 8, 2026
Merged

fix(cketh): derive the balance-scan batch size from the EIP-3860 initcode limit#11489
gregorydemay merged 4 commits into
masterfrom
gdemay/DEFI-2996-balance-scan-initcode-limit

Conversation

@gregorydemay

@gregorydemay gregorydemay commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Reported in the forum.

Problem

  • The balance scan reads ERC-20 balances with a create-style eth_call that runs the deployless batcher as init code.
  • EIP-3860 caps initcode at 49152 bytes. With 165 bytes of program, one length word and 64 bytes per call, at most 764 calls fit.
  • The batch size was 1000, chosen from the provider gas cap alone.
  • A chunk above the limit is rejected by every node, retried whole on the next tick, and fails again. Its deposits are never detected.

Changes

  • The batch size is derived from the batcher encoding instead of a literal, which yields 764 calls today.
  • An integration test against anvil checks that a full batch succeeds and one more call is rejected with max initcode size exceeded.
  • A unit test pins the encoded size of a full batch to the initcode limit.
  • The design doc states the bound, links EIP-3860 and describes the chunking.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AV18LEDjdNim5BecwhcqeV

gregorydemay and others added 3 commits September 8, 2026 09:47
…3860 initcode limit

* A full batch of MAX_CALLS_PER_BATCH balanceOf calls is rejected by anvil with "max initcode size exceeded".
* The encoding is 165 bytes of init code, one length word and 64 bytes per call, so at most 764 calls fit in 49152 bytes.
* The test fails until the cap is lowered.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AV18LEDjdNim5BecwhcqeV
…atches

* One create-style eth_call carries at most 764 pairs because initcode is capped at 49152 bytes.
* Larger watchlists are split into several calls per tick, each retried whole on failure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AV18LEDjdNim5BecwhcqeV
…P-3860 initcode limit

* A create-style eth_call is bounded by the 49152-byte initcode limit, not only by the provider gas cap.
* The batch size is now derived from the encoding, which yields 764 calls for the current batcher.
* A chunk that always exceeded the limit was retried whole every tick and its deposits were never detected.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AV18LEDjdNim5BecwhcqeV

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.

🟢 Approval recommended

The reviewed changes have no unresolved approval-blocking issues.

Pull request overview

Derives the ckETH balance-scan batch limit from EIP-3860’s initcode ceiling to prevent oversized batches from failing indefinitely.

Changes:

  • Replaces the 1,000-call limit with a derived 764-call limit.
  • Adds boundary unit and Anvil integration tests.
  • Documents the limit and chunking behavior.
File summaries
File Description
rs/ethereum/cketh/minter/tests/deposit_from_cex.rs Verifies Anvil accepts 764 calls and rejects 765.
rs/ethereum/cketh/minter/src/balance_scan/mod.rs Uses the derived batch limit.
rs/ethereum/cketh/minter/src/balance_scan/batcher/tests.rs Tests encoded-size boundaries.
rs/ethereum/cketh/minter/src/balance_scan/batcher/mod.rs Derives the maximum batch size.
rs/ethereum/cketh/docs/deposit_from_cex.md Documents EIP-3860 chunking.
Review details
  • Files reviewed: 5/5 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.

@gregorydemay gregorydemay changed the title fix(cketh): DEFI-2996: derive the balance-scan batch size from the EIP-3860 initcode limit fix(cketh): derive the balance-scan batch size from the EIP-3860 initcode limit Sep 8, 2026
@gregorydemay
gregorydemay marked this pull request as ready for review September 8, 2026 10:37
@gregorydemay
gregorydemay requested a review from a team as a code owner September 8, 2026 10:37
@github-actions github-actions Bot added the @defi label Sep 8, 2026
@zeropath-ai

zeropath-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to a050db4.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/ethereum/cketh/minter/src/balance_scan/batcher/mod.rs
     Add MAX_CODE_SIZE, MAX_INITCODE_SIZE, and MAX_CALLS_PER_BATCH constants to enforce EIP-170/EIP-3860 limits for deployless batch calls
Enhancement ► rs/ethereum/cketh/minter/src/balance_scan/batcher/tests.rs
     Add test full_batch_fits_the_initcode_limit_and_one_more_call_does_not
Enhancement ► rs/ethereum/cketh/minter/src/balance_scan/mod.rs
     Import MAX_CALLS_PER_BATCH from batcher and remove outdated inline comment about MAX_CALLS_PER_BATCH
Enhancement ► rs/ethereum/cketh/minter/tests/deposit_from_cex.rs
     Update imports to include MAX_CALLS_PER_BATCH, MAX_CALLS_PER_BATCH usage in tests for batch sizing and boundary behavior

Comment thread rs/ethereum/cketh/minter/tests/deposit_from_cex.rs Outdated
Comment thread rs/ethereum/cketh/minter/src/balance_scan/mod.rs Outdated
Comment thread rs/ethereum/cketh/minter/src/balance_scan/batcher/mod.rs Outdated
Address review feedback on the batch-size derivation:
- derive MAX_CALLS_PER_BATCH from both the EIP-3860 initcode limit and
  the EIP-170 code-size limit on the returned blob, taking the smaller,
  so the cap stays valid if the batcher encoding ever changes shape
- fund the last holder of the full-batch anvil test so the assertion
  proves the offset arithmetic addressed pair 763, not just that an
  all-zero blob of the right size came back
- drop the redundant re-export of MAX_CALLS_PER_BATCH from balance_scan

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9

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.

🟢 Approval recommended

The reviewed changes have appropriate boundary coverage and no unresolved issues.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@gregorydemay
gregorydemay added this pull request to the merge queue Sep 8, 2026
Merged via the queue into master with commit 7d3c4f1 Sep 8, 2026
45 checks passed
@gregorydemay
gregorydemay deleted the gdemay/DEFI-2996-balance-scan-initcode-limit branch September 8, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants