Skip to content

Conversation

@Helkomine
Copy link

This PR introduces a draft EIP proposing two new EVM opcodes, MLOAD8 and CALLDATALOAD8, which allow efficient single-byte access to memory and calldata.

A discussion thread has been opened on Ethereum Magicians: https://ethereum-magicians.org/t/eip-xxxx-mload8-and-calldataload8-opcodes/27396

This EIP introduces new EVM opcodes for efficient single-byte memory and calldata loads, reducing gas costs and bytecode size.
Added details for MLOAD8 and CALLDATALOAD8 instructions, including stack inputs, outputs, gas costs, and exceptional conditions.
Clarified opcode references in the abstract and motivation sections.
Propose new opcodes for direct single-byte loading to reduce gas costs and bytecode size.
@Helkomine Helkomine requested a review from eth-bot as a code owner January 7, 2026 10:58
@github-actions github-actions bot added c-new Creates a brand new proposal s-draft This EIP is a Draft labels Jan 7, 2026
@eth-bot
Copy link
Collaborator

eth-bot commented Jan 7, 2026

File EIPS/eip-8120.md

Requires 1 more reviewers from @g11tech, @jochem-brouwer, @lightclient, @SamWilsn

@github-actions github-actions bot added the w-ci Waiting on CI to pass label Jan 7, 2026
@github-actions github-actions bot added t-core and removed w-ci Waiting on CI to pass labels Jan 7, 2026
@eth-bot eth-bot added e-consensus Waiting on editor consensus e-review Waiting on editor to review labels Jan 7, 2026
@eth-bot eth-bot changed the title Add EIP-XXXX: MLOAD8 and CALLDATALOAD8 Add EIP: MLOAD8 and CALLDATALOAD8 Opcodes Jan 7, 2026
@github-actions github-actions bot added the w-ci Waiting on CI to pass label Jan 7, 2026
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

The commit 5e819b8 (as a parent of 61d002c) contains errors.
Please inspect the Run Summary for details.

@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Jan 7, 2026
EIPS/eip-9999.md Outdated
@@ -0,0 +1,103 @@
---
eip: 9999
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
eip: 9999
eip: 8120

Assigning next sequential EIP/ERC/RIP number.
Numbers are assigned by editors & associates.

Please also update the filename.

EIPS/eip-9999.md Outdated
title: MLOAD8 and CALLDATALOAD8 Opcodes
description: Adds EVM opcodes for efficient single-byte memory and calldata loads.
author: Helkomine (@Helkomine)
discussions-to: https://ethereum-magicians.org/t/eip-xxxx-mload8-and-calldataload8-opcodes/27396
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
discussions-to: https://ethereum-magicians.org/t/eip-xxxx-mload8-and-calldataload8-opcodes/27396
discussions-to: https://ethereum-magicians.org/t/eip-8120-mload8-and-calldataload8-opcodes/27396

Updated with assigned number. Recommend using the template for the discussions topic.

Copy link
Contributor

@xinbenlv xinbenlv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this proposal! The addition of MLOAD8 and CALLDATALOAD8 fills a clear gap in the EVM instruction set, offering symmetry with MSTORE8 and potential gas savings for byte-oriented processing. The draft is well-written and follows the standard structure.

The proposal is solid and ready for Draft status once the ambiguity regarding memory expansion size (1 byte vs 32 bytes) is resolved in the text.


## Specification

### MLOAD8 (TBD)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While (TBD) is acceptable for an initial draft, consider proposing specific opcode values (e.g., from the 0x5X range if available) to facilitate early client prototyping and collision checking.

- **Stack output**: `value`

Reads one byte from memory at position offset and pushes it onto the stack as a 32-byte word, with the byte placed in the least significant position.
If offset is greater than or equal to the current memory size, the returned value is 0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrasing here could be interpreted as returning 0 without expanding memory. In the EVM, accessing memory beyond the current size typically triggers expansion (and the cost associated with it) first, and the value is 0 because the new memory is zero-initialized.

Consider clarifying that expansion happens first, or simply rely on the expansion rule definition.


Reads one byte from memory at position offset and pushes it onto the stack as a 32-byte word, with the byte placed in the least significant position.
If offset is greater than or equal to the current memory size, the returned value is 0.
Memory expansion rules apply in the same way as for `MLOAD`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reference to MLOAD might be ambiguous regarding the size of the expansion. MLOAD reads 32 bytes, so it expands memory to cover offset + 32. MLOAD8 should presumably only expand to offset + 1 (like MSTORE8).

Suggested change
Memory expansion rules apply in the same way as for `MLOAD`.
Memory expansion rules apply in the same way as for `MSTORE8` (extending memory to at least `offset + 1` bytes).


### Efficiency for Byte-Oriented Contracts

Instruction-based architectures, such as instruction-based routers used in decentralized exchange protocols, benefit from reduced gas usage and smaller bytecode size when parsing byte streams.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be valuable to include a concrete calculation of the savings here to strengthen the rationale.

For example: "Replacing CALLDATALOAD (3 gas) + PUSH (3 gas) + SHR (3 gas) with CALLDATALOAD8 (3 gas) saves 6 gas per byte read and reduces bytecode size by ~3 bytes."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c-new Creates a brand new proposal e-consensus Waiting on editor consensus e-review Waiting on editor to review s-draft This EIP is a Draft t-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants