lfglabs-dev / lfglabs-dev/verity
feat(CodeData): typed byte-layout proof surface for CREATE2/SSTORE2 code-as-storage
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 148
- Forks
- 20
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 29
Description
Motivation
morpho-midnight-verity keeps its IdLib/SSTORE2 machinery behind ECMs because Verity has no typed surface for byte-exact code/data layouts. The affected modules (Midnight/Contract.lean ~1304–1780) carry 5 distinct ECM axioms:
midnight_idlib_toid_market_abi_create2_preimage(2 sites —marketIdModule,marketIdAtOffsetModule):IdLib.toIdoverSSTORE2_PREFIX ++ abi.encode(market)implements the real preimage but can't be expressed as typed sourcemidnight_sstore2_market_initcode_layout+create2_address_derivation(2 sites —storeMarketInCodeModuleand the touch path): CREATE2-SSTORE2 storage where the emitted Yul is the source algorithm; typedCodeData.store[Market]is the intended replacementmidnight_sstore2_market_runtime_abi_decode/midnight_sstore2_market_runtime_abi_return: reading back the stored runtime code and decoding/returning the Market payload
Proposed surface
CodeDatalayout type: a first-class description ofprefix ++ payloadbyte layouts (SSTORE2-style: STOP-prefixed runtime code carrying an ABI-encoded payload), with lemmas relating layout length/offsets to the payload encoding.- Preimage construction: a verified builder for
initcodethat returns the given runtime code, with a theorem that the deployed code equalsprefix ++ payload(initcode layout proof — killsmidnight_sstore2_market_initcode_layout). - CREATE2 address derivation: model-level
create2Address salt initcodeHash deployerwith the keccak preimage structured as a typed record rather than raw bytes, so theIdLib.toIdpreimage becomes a definitional unfolding (kills*_create2_preimage;create2_address_derivationbecomes a model definition rather than an axiom). - Round-trip decode:
CodeData.load[T]withdecode (encode x) = xfor supported payload types (kills the runtime decode/return axioms).
Dependencies / notes
- Payloads like
Marketare dynamic structs, so the decode half depends on the dynamic ABI codec work (#1982 family / Tier 1: #1975, #1889). - The address-derivation and initcode-layout halves are independent of #1982 and can land first.
- Downstream goal: replace the 6 ECM axiom occurrences in morpho-midnight-verity with typed
CodeData.store/CodeData.loadcalls plus per-contract certificates.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Midnight/Contract.lean, around lines 1304–1780, and inspect the six ECM axioms and their sites in marketIdModule, marketIdAtOffsetModule, storeMarketInCodeModule, and the touch path. Review the dynamic ABI codec dependencies in #1982, #1975, and #1889. Done means a typed CodeData surface covers the independent initcode and CREATE2 pieces, with the decode work aligned to the codec dependency and the downstream axioms replaceable.
Written by the indexing model from the issue text.
Assessment
- Domain
- blockchain
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100