Expand description
The cmd_executor command-stream grammar — solver result → the bytes
the on-chain cmd_executor.execute(bytes, config) contract runs.
A pyo3-free core leaf (ADR-005 standalone surface) with two modules:
- The command grammar (the bulk of this crate): the per-protocol hop
facts + the plan walker that derives the enclosure and emits a
grammar_plan::Plan(grammar_walker), the ledger validator that gates every Plan (grammar_ledger), the shape-class deriver (grammar_shape), the opcode builders (encoders), theexecuteconfig packing (config), and the public intake —composers::EncodeContext+composers::EncodeRequest→composers::encode_cmd_stream(ADR-033). The ADR-029/030/031 record records own the grammar’s invariants (axes, tri-state outcomes, the facts-driven walker). - The warmup-slot math (
WarmupSlots/compute_simulation_warmup_slots): the Solidity storage-slot math that feeds simulation state-override warmup — three slots pre-warmed so injected runtime bytecode (noinitialize()call) sees warm storage, replicatingcmd_executor.initialize()’s cold-SSTORE avoidance (~22,100 gas/slot).
§Warmup-slot storage layout
- WETH9
balanceOfat mapping slot 3 (name@0,symbol@1,decimals@2 — all occupy storage, notconstant). - PoolManager ERC6909
balanceOfat mapping slot 4 (C3 linearization ofPoolManager is ProtocolFees, ERC6909Claims, …:owner@0,pendingOwner@1,isOperator@2,protocolFeesAccrued@3,balanceOf@4). - ERC6909 id =
uint160(currency)perCurrencyLibrary.toId()— the native id isuint160(address(0)) = 0.
WarmupSlots carries the three computed slot addresses only
(U256); the warmed balance values + the eth_simulateV1
{address: {"stateDiff": {slot_hex: value_hex}}} dict shape are a thin
PyO3 adapter concern, not a core one.
§Parity
The warmup slots are byte-for-byte parity vs
cmd_executor.initialize()’s storage layout (§4.2) — canonical mainnet
WETH (0xC02…) / PoolManager (0x0000…444c). The grammar’s byte-identity
is pinned by the golden corpus + the revm runtime matrix
(degenbot-simulation).
Modules§
- composers
- 2-hop + N-hop command-stream path composers.
- config
- The
execute(commands, config)ABIconfiguint256packing. - encoders
- Command-stream primitives — opcode constants,
AddressTable, and apub fn enc_*builder for every opcode (0x00–0x59,0xFF). - grammar_
ledger - Executor grammar — full axis model (GCC6I6) + a ledger-validator that makes the two real bug classes unrepresentable (ADR-029 D1/D2, D5).
- grammar_
plan - The Plan walker — the deep, stable half of the grammar (
grammar_shape.rssplit, ERP6ES / candidate 2 ofarchitecture-review-1786663110.html). - grammar_
shape - Builders — the per-family dispatch surface + validator gate
(
grammar_shape.rssplit, ERP6ES / candidate 2 ofarchitecture-review-1786663110.html). - grammar_
walker - ADR-031 D6 — the sole facts-driven Plan producer (epic
6SU5LM).
Structs§
- Warmup
Slots - The three computed warmup slot addresses for
eth_simulateV1stateDiffoverrides.
Constants§
- POOL_
MANAGER_ ERC6909_ BALANCE_ OF_ SLOT - The PoolManager ERC6909
balanceOfmapping storage slot (C3 linearization:owner@0,pendingOwner@1,isOperator@2,protocolFeesAccrued@3,balanceOf@4). - WETH9_
BALANCE_ OF_ SLOT - The WETH9
balanceOfmapping storage slot (name@0,symbol@1,decimals@2,balanceOf@3).
Functions§
- compute_
simulation_ warmup_ slots - Compute the three
eth_simulateV1warmup slot addresses that replicate the effect ofcmd_executor.initialize(). - erc6909_
id - Derive the ERC6909 token id for a currency:
uint160(currency)perCurrencyLibrary.toId()(the low 160 bits of the address’s integer form). - mapping_
slot - Compute a Solidity mapping storage slot:
keccak256(key ‖ base_slot), both 32-byte big-endian. - nested_
mapping_ slot - Compute the storage slot for
mapping[key1][key2]atbase_slot:mapping_slot(mapping_slot(base_slot, key1), key2).