-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added EIP-2330: EXTSLOAD #2330
Added EIP-2330: EXTSLOAD #2330
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
--- | ||
eip: 2330 | ||
title: SLOAD2 | ||
title: EXTSLOAD | ||
author: Dominic Letz (@dominicletz) | ||
discussions-to: https://ethereum-magicians.org/t/eip-2330-sload2-and-abi-for-lower-gas-cost-and-off-chain-apps/3733 | ||
discussions-to: https://ethereum-magicians.org/t/eip-2330-extsload-and-abi-for-lower-gas-cost-and-off-chain-apps/3733 | ||
status: Draft | ||
type: Standards Track | ||
category: Core | ||
|
@@ -13,23 +13,23 @@ created: 2019-10-29 | |
|
||
## Simple Summary | ||
<!--"If you can't explain it simply, you don't understand it well enough." Provide a simplified and layman-accessible explanation of the EIP.--> | ||
A new `SLOAD2 <address> <slot>` EVM opcode to read external contract storage data and corresponding allowing to build registry and token contracts that use less gas. | ||
A new `EXTSLOAD <contract> <slot>` EVM opcode to read external contract storage data and corresponding allowing to build registry and token contracts that use less gas. | ||
|
||
## Abstract | ||
<!--A short (~200 word) description of the technical issue being addressed.--> | ||
While any off-chain application can read all contract storage data of all contracts, this is not possible for deployed smart contracts themselves. These are bound to use contract calls for any interaction including reading data from other contracts. This EIP adds an EVM opcode to directly read external contract storage. | ||
|
||
## Motivation | ||
<!--The motivation is critical for EIPs that want to change the Ethereum protocol. It should clearly explain why the existing protocol specification is inadequate to address the problem that the EIP solves. EIP submissions without sufficient motivation may be rejected outright.--> | ||
The gas cost when reading from registry style contract such as ERC-20s, ENS and other data contracts is very high, because they incur cross contract call cost, cost for ABI encoding, decoding and dispatching and finally loading the data. In many cases the underlying storage that is being queried is though just a simple mapping. In these cases a new SLOAD2 call directly accessing the mapping in storage could not only **reduce the gas cost** of the interaction more than 10x, but also it would make the gas cost **predictable** for the reading contract. | ||
The gas cost when reading from registry style contract such as ERC-20s, ENS and other data contracts is very high, because they incur cross contract call cost, cost for ABI encoding, decoding and dispatching and finally loading the data. In many cases the underlying storage that is being queried is though just a simple mapping. In these cases a new `EXTSLOAD` call directly accessing the mapping in storage could not only **reduce the gas cost** of the interaction more than 10x, but also it would make the gas cost **predictable** for the reading contract. | ||
|
||
## Specification | ||
<!--The technical specification should describe the syntax and semantics of any new feature. The specification should be detailed enough to allow competing, interoperable implementations for any of the current Ethereum platforms (go-ethereum, parity, cpp-ethereum, ethereumj, ethereumjs, and [others](https://github.com/ethereum/wiki/wiki/Clients)).--> | ||
**Proposal** | ||
A new EVM instruction `SLOAD2 (0x5c)` that works like `SLOAD (0x54)` with the same gas cost but has an additional parameter representing the contract that is to be read from. | ||
A new EVM instruction `EXTSLOAD (0x5c)` that works like `SLOAD (0x54)` with the gas cost of EXTCODE(700) + SLOAD(800) = 1500 and an additional parameter representing the contract that is to be read from. | ||
|
||
``` | ||
SLOAD (0x5c) | ||
EXTSLOAD <contract> <slot> (0x5c) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this specification is a bit confusing. Is it having two immediate parameters? Is it taking those from the stack? Please check out https://eips.ethereum.org/EIPS/eip-1052 and https://eips.ethereum.org/EIPS/eip-145 as examples on the specification section. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I've looked at those and (hopefully) clarified the specification accordingly. |
||
``` | ||
|
||
**Example** | ||
|
@@ -51,7 +51,7 @@ function membersOnly(address list, address member) { | |
} | ||
``` | ||
|
||
The call `ml.members[client]` here could let the Solidity compiler generate the normal map access logic but using the new `SLOAD2 <address> <slot>` instructions to read from the `ml` contract storage instead of the local contract storage. | ||
The call `ml.members[client]` here could let the Solidity compiler generate the normal map access logic but using the new `EXTSLOAD <contract> <slot>` instructions to read from the `ml` contract storage instead of the local contract storage. | ||
|
||
## Backwards Compatibility | ||
This change is fully backwards compatible since it adds a new instruction. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you want to extend the title a bit like "EXTSLOAD opcode".