Expand description
Storage layouts for contracts that are not part of the local project.
When a forked test touches a contract that isnβt in the local artifacts, its storage slots can still be decoded by compiling the verified source a block explorer has for it.
Finding that source is the callerβs job β foundry-evm-traces already knows how to ask a block
explorer for it. This module owns what happens next: compiling it for a storage layout, which
costs a full solc invocation, and making sure that cost is paid once.
forge test runs test contracts in parallel, so lookups are:
- deduplicated process-wide by
LOOKUPS, so concurrent tests touching the same contract compile it once instead of racing each other; - persisted to disk once resolved, so later runs skip straight to the layout.
Unverified responses are memoized only for this run so later runs can discover newly verified contracts.
StructsΒ§
- Cached
Storage πLayout - Disk representation of a resolved lookup. Cleared by
forge cache clean.
ConstantsΒ§
- BASE_
PATH_ πSOLC - First solc release with
--base-pathsupport. - CACHE_
VERSION π - Current
CachedStorageLayoutformat. - MIN_
STORAGE_ πLAYOUT_ SOLC - First solc release that emits
storageLayout. Matches the floorcast storageenforces. - NO_
IMPORT_ πCALLBACK_ SOLC - First solc release with
--no-import-callbacksupport.
StaticsΒ§
- CACHE_
TEMP_ πID - Makes cache publication paths unique within one process; the PID separates processes.
- COMPILER π
- Bounds expensive compiler installation and execution across parallel tests.
- LOOKUPS π
- Per-(chain, address) lookup slots, shared across the whole process.
FunctionsΒ§
- cache_
path π - Path of the cache entry for
address. - compile_
storage_ πlayout - Compiles a verified source with
storageLayoutoutput enabled and extracts the layout. - fetch_
external_ storage_ layouts - Resolves the storage layouts of
addressesonchain, compiling verified sources as needed. - lock_
until - Acquires a lock without exceeding the callerβs deadline.
- read_
cached_ πlayout - Reads the layout a previous run resolved for
address, if there is one. - resolve π
fetch_external_storage_layoutswith the cache location supplied, so tests can point it somewhere other than the userβs home directory.- run_
solc π - Runs solc in an empty directory and terminates it if the remaining lookup budget expires.
- write_
cached_ πlayout - Persists a resolved layout so later runs can skip the fetch and the compile.
Type AliasesΒ§
- External
Storage πLayout - A resolved storage layout, or
Noneif the contract has no layout we can use. - Lookup
Slot π - A single addressβ lookup slot:
Noneuntil the lookup completes, then its memoized result.