Modified key discovery returns the keys for entries in a known Solidity mapping that were written during a transaction. Use ph.changedMappingKeys to enumerate written keys and ph.mappingValueDiff to read each entry’s pre- and post-transaction values.
Status
The current Phylax app and Linea deployment support the V1 assertion specification. Use these helpers for local or development workflows until the target deployment supports V2.
Interface
baseSlot is the mapping’s declared storage slot. Each returned key is the encoded mapping-key preimage used to derive keccak256(key ++ baseSlot). For a mapping whose value is a struct, set fieldOffset to the field’s offset from the derived entry slot.
Example
Behavior and Constraints
- Discovery is scoped to entries written by the current transaction. It includes same-value
SSTORE operations, for which mappingValueDiff returns changed as false.
- The mapping base slot and any struct field offset must be known.
- Discovery is best effort. Custom inline assembly or precomputed hashed storage slots can prevent the runtime from recovering a key.
- Nested mappings are not discoverable from the outer mapping slot because the outer entry hash is used as the inner base slot rather than written to storage.
Uses
- Validate limits for every balance or position modified by a transaction.
- Reconcile modified entries against aggregate accounting.
- Apply field-specific checks to mapping values stored as structs.