EIP-7834 · Review · Core · 2024-12-06
EIP-7834: Separate Metadata Section for EOF
Proposes an optional, code-unreachable metadata section in EOF containers so compiler metadata no longer shifts executable bytecode or confuses source verification.
What problem does it solve?
Solidity and Vyper append metadata to contract bytecode by default: the compiler version and, for Solidity, an IPFS or Swarm hash of the metadata JSON, CBOR-encoded and followed by a 2-byte length. Source verifiers such as block explorers must strip it before comparing on-chain code with a fresh compile. Because legacy bytecode has no structure, they rely on heuristics, and factory contracts with nested bytecode make it worse.
The EVM Object Format (EIP-3540) adds structure: separate code and data sections. But with no dedicated place for metadata, compilers would put it in the data section, where:
- it is still hard to tell apart from real data;
- a change in metadata size shifts data offsets (e.g.
DATALOADNimmediates from EIP-7480), so two contracts with identical logic produce different code; - code could, in theory, read it.
How it works
EIP-7834 adds an optional metadata_section to the EOF container body, placed after any container sections and before the data section, with a matching header entry:
| Header field | Size | Value |
|---|---|---|
kind_metadata |
1 byte | 0x05 |
metadata_size |
2 bytes | 0x0001–0xFFFF, big-endian |
The header entry sits just before kind_data (0xff). Code cannot reach the section, and the EIP does not define its encoding; compilers are expected to keep using CBOR.
Why before the data section? Data can grow during deployment (EOF allows appending to data), which would otherwise move the metadata. Why 0x05 instead of the next free kind? To ease adoption by existing EOF tooling.
Sample code
Container grammar with the new optional fields:
header :=
magic, version,
kind_type, type_size,
kind_code, num_code_sections, code_size+,
[kind_container, num_container_sections, container_size+,]
[kind_metadata, metadata_size,] ; NEW, 0x05
kind_data, data_size,
terminator
body := types_section, code_section+, container_section*,
[metadata_section], ; NEW
data_section
A verifier can then compare everything except the metadata bytes (TypeScript sketch):
function stripMetadata(container: EofContainer): Uint8Array {
// With a dedicated section, no heuristics are needed:
return container.serialize({ omitSections: ["metadata"] });
}
const match = equal(stripMetadata(onchain), stripMetadata(compiled));
EofContainer here is a hypothetical parser type, not a specific library.
Things to know
- Status: Review. It extends EOF, which itself is Stagnant: EOF (EIP-3540, meta EIP-7692) was removed from the Fusaka upgrade and is not active on mainnet. This EIP only matters if EOF is revived.
- No backwards compatibility concerns, since EOF was never deployed.
- Legacy (non-EOF) contracts are unaffected; verifiers still need today's heuristics for them.