Skip to content

Commit eb6589e

Browse files
gregorydemayclaude
andcommitted
docs(cketh): state why an empty code prefix means no delegation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X44H4nAU65nAexEUvG15MK
1 parent afea681 commit eb6589e

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

  • rs/ethereum/cketh/minter/src/balance_scan/batcher

rs/ethereum/cketh/minter/src/balance_scan/batcher/mod.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,23 @@ pub fn encode_delegation_batch(addresses: &[DepositAddress]) -> Vec<u8> {
242242
/// Decode the flat `n x 32`-byte return blob of [`DELEGATION_BATCHER_INITCODE`] into `n`
243243
/// delegations, in call order.
244244
///
245-
/// Each word is the first 32 bytes of an account's code, zero-padded beyond its size, which
246-
/// classifies the account unambiguously:
247-
/// * an all-zero word means no code at all, since [EIP-3541] forbids deploying code starting
248-
/// with `0xef` and a shorter non-empty code would still carry a non-zero first byte;
245+
/// Each word is the first 32 bytes of an account's code, zero-padded beyond its size. The
246+
/// accounts read are [`DepositAddress`]es, whose address is the hash of a public key the minter
247+
/// derives, never the hash of a deployer and nonce or of `CREATE2` inputs, so no contract can be
248+
/// deployed at one and the only code such an account can ever hold is a delegation designator.
249+
/// That classifies each word unambiguously:
250+
/// * an all-zero word means no code at all, hence no delegation;
249251
/// * `0xef0100 || delegate || 9 zero bytes` is a code of exactly 23 bytes whose only possible
250-
/// origin is an applied [EIP-7702] authorization tuple — again because EIP-3541 keeps every
251-
/// deployed contract out of the `0xef` space;
252+
/// origin is an applied [EIP-7702] authorization tuple, since [EIP-3541] keeps every deployed
253+
/// contract out of the `0xef` space;
252254
/// * anything else is deployed contract code.
253255
///
254256
/// Returns `Err` if the blob length is not exactly `n` words; never panics.
255257
///
258+
/// The first classification rests on the account being a deposit address and does not generalize:
259+
/// [EIP-3541] reserves only the `0xef` prefix, so a contract whose runtime code starts with 32
260+
/// zero bytes — `STOP` padded out, say — would read as [`Delegation::NotDelegated`] here.
261+
///
256262
/// [EIP-3541]: https://eips.ethereum.org/EIPS/eip-3541
257263
/// [EIP-7702]: https://eips.ethereum.org/EIPS/eip-7702
258264
pub fn decode_delegation_batch(

0 commit comments

Comments
 (0)