{"eip":7519,"title":"Atomic Storage Operations SCREDIT and SDEBIT","description":"Add atomic operations for incrementing and decrementing storage slots","authors":["Danno Ferrin (@shemnon)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2023-09-16","requires":[2200,2929],"discussionsTo":"https://ethereum-magicians.org/t/eip-7519-atomic-storage-operations-scredit-and-sdebit/15818","repo":"EIPs","label":"EIP-7519","officialUrl":"https://eips.ethereum.org/EIPS/eip-7519","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7519.md","url":"https://eips.huatuo.xyz/eip-7519/","tldr":{"en":"Proposed two EVM opcodes, SCREDIT and SDEBIT, that add to or subtract from a storage slot in one step with overflow checks, giving parallel EVMs a safe primitive for balances and counters.","ja":"SCREDIT と SDEBIT という 2 つの EVM opcode を提案する。オーバーフロー検査付きでストレージスロットへの加算・減算を 1 ステップで行い、並列 EVM に残高やカウンター向けの安全なプリミティブを提供する。","ko":"SCREDIT와 SDEBIT라는 두 EVM opcode를 제안한다. 오버플로 검사와 함께 스토리지 슬롯에 한 번에 더하거나 빼서, 병렬 EVM에 잔액과 카운터를 위한 안전한 기본 요소를 제공한다.","zh":"提议新增两个 EVM 操作码 SCREDIT 和 SDEBIT，一步完成对存储槽的加法或减法并带溢出检查，为并行 EVM 提供用于余额和计数器的安全原语。"},"tags":["evm","opcodes","storage","parallel-execution","core"],"explainers":{"en":{"lang":"en","tldr":"Proposed two EVM opcodes, SCREDIT and SDEBIT, that add to or subtract from a storage slot in one step with overflow checks, giving parallel EVMs a safe primitive for balances and counters.","tags":["evm","opcodes","storage","parallel-execution","core"],"related":[2200,2929,1153],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7519/","markdown":"## What problem does it solve?\n\nMany chains, especially Layer 2s, are experimenting with executing transactions in parallel. The usual approach is optimistic concurrency control: run transactions side by side, then re-run any whose reads were invalidated by another transaction's writes. That breaks down for the most common write of all, updating a balance or counter. Two transfers that both touch the same balance always conflict, even though \"add 5\" and \"subtract 3\" could be applied in either order.\n\nEIP-7519 adds opcodes that express \"add to this slot\" and \"subtract from this slot\" directly. Because the EVM knows the intent, a parallel engine only has to check that the slot cannot overflow or underflow under any ordering, not that every read stayed the same.\n\n## How it works\n\nTwo opcodes, each popping two stack items (`slot`, `value`) and pushing nothing. Opcode numbers are still `TBD` in the spec.\n\n| Opcode | Effect | Fails when |\n| --- | --- | --- |\n| `SCREDIT` | `storage[slot] += value` | the result would be ≥ 2^256 |\n| `SDEBIT` | `storage[slot] -= value` | the result would be \u003c 0 |\n\nOn overflow or underflow the frame **halts exceptionally** (all gas in the frame is consumed), unlike the silent wrap-around of `ADD`/`SUB`.\n\nGas is charged **exactly like `SSTORE`**, including the warm/cold slot rules of [EIP-2929](/eip-2929/) and the net-metering of [EIP-2200](/eip-2200/), and any future `SSTORE` repricing applies automatically. The spec argues the extra work (an add and compare) is negligible next to the storage I/O.\n\nOnly persistent storage is covered. Transient storage ([EIP-1153](/eip-1153/)) is excluded because there is no parallelism inside a single transaction.\n\n## Sample code\n\nThe opcode replaces this load / check / store sequence. Today in Solidity:\n\n```solidity\n// What SDEBIT(slot, amount) and SCREDIT(slot, amount) do, written with today's opcodes\nmapping(address =\u003e uint256) internal balanceOf;\n\nfunction _transfer(address from, address to, uint256 amount) internal {\n    balanceOf[from] -= amount;   // SLOAD, SUB with underflow check, SSTORE  -\u003e SDEBIT\n    balanceOf[to]   += amount;   // SLOAD, ADD with overflow check,  SSTORE  -\u003e SCREDIT\n}\n```\n\nExecution pseudocode from the spec, condensed:\n\n```python\ndef scredit(slot, value):\n    new = storage[slot] + value\n    if new \u003e= 2**256:\n        raise ExceptionalHalt(\"scredit overflow\")\n    storage[slot] = new\n\ndef sdebit(slot, value):\n    new = storage[slot] - value\n    if new \u003c 0:\n        raise ExceptionalHalt(\"sdebit underflow\")\n    storage[slot] = new\n```\n\n## Things to know\n\n- Status is **Stagnant**. The opcodes have no assigned byte values and are not scheduled for any Ethereum upgrade.\n- The spec states general concurrency primitives (locks, semaphores) are out of scope; the target is token balances and similar counters.\n- An exceptional halt consumes all gas in the current call frame, which is harsher than Solidity's checked-arithmetic `revert`. Callers should account for this.\n- The new failure point is something auditors would need to consider when reasoning about reentrancy.\n- Implementing the operations as a system contract instead of opcodes was considered, mainly for L2s, but rejected because of the code size needed for each call.\n"},"ja":{"lang":"ja","tldr":"SCREDIT と SDEBIT という 2 つの EVM opcode を提案する。オーバーフロー検査付きでストレージスロットへの加算・減算を 1 ステップで行い、並列 EVM に残高やカウンター向けの安全なプリミティブを提供する。","tags":["evm","opcodes","storage","parallel-execution","core"],"related":[2200,2929,1153],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7519/","markdown":"## 何を解決するのか\n\n多くのチェーン、特にレイヤー 2 は、トランザクションの並列実行を試みています。一般的な方法は楽観的並行性制御です。トランザクションを並べて実行し、他のトランザクションの書き込みによって読み取りが無効になったものを再実行します。しかし、最もありふれた書き込みである残高やカウンターの更新では、これが破綻します。同じ残高に触れる 2 つの送金は、「5 を足す」と「3 を引く」がどちらの順序で適用されても構わないにもかかわらず、常に衝突します。\n\nEIP-7519 は「このスロットに加算する」「このスロットから減算する」を直接表現する opcode を追加します。EVM が意図を把握できるため、並列エンジンは、すべての読み取りが同じままであることではなく、どの順序でもスロットがオーバーフローやアンダーフローしないことだけを確認すればよくなります。\n\n## 仕組み\n\n2 つの opcode はそれぞれスタックから 2 つの要素（`slot`、`value`）を pop し、何も push しません。opcode の番号は仕様ではまだ `TBD` です。\n\n| Opcode | 効果 | 失敗する条件 |\n| --- | --- | --- |\n| `SCREDIT` | `storage[slot] += value` | 結果が 2^256 以上になる場合 |\n| `SDEBIT` | `storage[slot] -= value` | 結果が 0 未満になる場合 |\n\nオーバーフローまたはアンダーフローが起きると、フレームは**例外的に停止**し（そのフレームのガスをすべて消費）、`ADD` / `SUB` のように黙ってラップアラウンドすることはありません。\n\nガスは [EIP-2929](/eip-2929/) のウォーム／コールドスロット規則や [EIP-2200](/eip-2200/) のネットメータリングを含め、**`SSTORE` とまったく同じ**ように課金され、将来の `SSTORE` の価格変更も自動的に適用されます。仕様は、追加の処理（加算と比較）はストレージ I/O に比べれば無視できると論じています。\n\n対象は永続ストレージのみです。単一のトランザクション内には並列性がないため、トランジェントストレージ（[EIP-1153](/eip-1153/)）は対象外です。\n\n## サンプルコード\n\nこの opcode は、ロード／検査／ストアの一連の処理を置き換えます。現在の Solidity では次のようになります。\n\n```solidity\n// What SDEBIT(slot, amount) and SCREDIT(slot, amount) do, written with today's opcodes\nmapping(address =\u003e uint256) internal balanceOf;\n\nfunction _transfer(address from, address to, uint256 amount) internal {\n    balanceOf[from] -= amount;   // SLOAD, SUB with underflow check, SSTORE  -\u003e SDEBIT\n    balanceOf[to]   += amount;   // SLOAD, ADD with overflow check,  SSTORE  -\u003e SCREDIT\n}\n```\n\n仕様の実行擬似コードを要約したもの:\n\n```python\ndef scredit(slot, value):\n    new = storage[slot] + value\n    if new \u003e= 2**256:\n        raise ExceptionalHalt(\"scredit overflow\")\n    storage[slot] = new\n\ndef sdebit(slot, value):\n    new = storage[slot] - value\n    if new \u003c 0:\n        raise ExceptionalHalt(\"sdebit underflow\")\n    storage[slot] = new\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。opcode にはバイト値が割り当てられておらず、どの Ethereum アップグレードにも予定されていません。\n- 仕様は、汎用の並行性プリミティブ（ロック、セマフォ）は対象外であり、狙いはトークン残高や同様のカウンターだと述べています。\n- 例外的停止は現在のコールフレームのガスをすべて消費するため、Solidity のチェック付き算術による `revert` より厳しい動作です。呼び出し側はこれを考慮してください。\n- 新たな失敗ポイントは、リエントランシーを検討する際に監査人が考慮すべきものになります。\n- 主に L2 向けに、opcode の代わりにシステムコントラクトとして実装することも検討されましたが、呼び出しごとに必要なコードサイズのために却下されました。\n"},"ko":{"lang":"ko","tldr":"SCREDIT와 SDEBIT라는 두 EVM opcode를 제안한다. 오버플로 검사와 함께 스토리지 슬롯에 한 번에 더하거나 빼서, 병렬 EVM에 잔액과 카운터를 위한 안전한 기본 요소를 제공한다.","tags":["evm","opcodes","storage","parallel-execution","core"],"related":[2200,2929,1153],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7519/","markdown":"## 어떤 문제를 해결하나요?\n\n많은 체인, 특히 레이어 2는 트랜잭션을 병렬로 실행하는 방법을 실험하고 있습니다. 일반적인 접근은 낙관적 동시성 제어입니다. 트랜잭션을 나란히 실행한 뒤, 다른 트랜잭션의 쓰기 때문에 읽은 값이 무효가 된 것을 다시 실행합니다. 하지만 가장 흔한 쓰기인 잔액이나 카운터 갱신에서는 이 방식이 무너집니다. 같은 잔액을 건드리는 두 전송은 \"5 더하기\"와 \"3 빼기\"를 어떤 순서로 적용해도 되는데도 항상 충돌합니다.\n\nEIP-7519는 \"이 슬롯에 더하기\"와 \"이 슬롯에서 빼기\"를 직접 표현하는 opcode를 추가합니다. EVM이 의도를 알기 때문에 병렬 엔진은 모든 읽기가 그대로인지가 아니라, 어떤 순서에서도 슬롯이 오버플로나 언더플로하지 않는지만 확인하면 됩니다.\n\n## 어떻게 동작하나요?\n\n두 opcode는 각각 스택에서 두 항목(`slot`, `value`)을 pop하고 아무것도 push하지 않습니다. opcode 번호는 사양에서 아직 `TBD`입니다.\n\n| Opcode | 효과 | 실패 조건 |\n| --- | --- | --- |\n| `SCREDIT` | `storage[slot] += value` | 결과가 2^256 이상이 될 때 |\n| `SDEBIT` | `storage[slot] -= value` | 결과가 0 미만이 될 때 |\n\n오버플로나 언더플로가 발생하면 프레임은 **예외적으로 중단**되며(프레임의 모든 가스 소비), `ADD`/`SUB`처럼 조용히 값이 감겨 돌아가지 않습니다.\n\n가스는 [EIP-2929](/eip-2929/)의 warm/cold 슬롯 규칙과 [EIP-2200](/eip-2200/)의 넷 미터링을 포함해 **`SSTORE`와 똑같이** 부과되며, 앞으로 `SSTORE` 가격이 조정되면 자동으로 적용됩니다. 사양은 추가 작업(덧셈과 비교)이 스토리지 I/O에 비하면 무시할 만하다고 주장합니다.\n\n영구 스토리지만 대상입니다. 트랜잭션 하나 안에는 병렬성이 없으므로 트랜지언트 스토리지([EIP-1153](/eip-1153/))는 제외됩니다.\n\n## 샘플 코드\n\n이 opcode는 로드 / 검사 / 저장 순서를 대체합니다. 지금의 Solidity에서는 이렇습니다.\n\n```solidity\n// What SDEBIT(slot, amount) and SCREDIT(slot, amount) do, written with today's opcodes\nmapping(address =\u003e uint256) internal balanceOf;\n\nfunction _transfer(address from, address to, uint256 amount) internal {\n    balanceOf[from] -= amount;   // SLOAD, SUB with underflow check, SSTORE  -\u003e SDEBIT\n    balanceOf[to]   += amount;   // SLOAD, ADD with overflow check,  SSTORE  -\u003e SCREDIT\n}\n```\n\n사양의 실행 의사코드를 간추린 것:\n\n```python\ndef scredit(slot, value):\n    new = storage[slot] + value\n    if new \u003e= 2**256:\n        raise ExceptionalHalt(\"scredit overflow\")\n    storage[slot] = new\n\ndef sdebit(slot, value):\n    new = storage[slot] - value\n    if new \u003c 0:\n        raise ExceptionalHalt(\"sdebit underflow\")\n    storage[slot] = new\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. opcode에는 바이트 값이 할당되지 않았고 어떤 이더리움 업그레이드에도 예정되어 있지 않습니다.\n- 사양은 범용 동시성 기본 요소(락, 세마포어)는 범위 밖이며 대상은 토큰 잔액과 유사한 카운터라고 밝힙니다.\n- 예외적 중단은 현재 콜 프레임의 가스를 모두 소비하므로 Solidity의 검사형 산술 `revert`보다 가혹합니다. 호출자는 이를 감안해야 합니다.\n- 이 새로운 실패 지점은 감사자가 재진입을 따질 때 고려해야 할 사항이 됩니다.\n- 주로 L2를 위해 opcode 대신 시스템 컨트랙트로 구현하는 방안도 검토되었지만, 호출마다 필요한 코드 크기 때문에 기각되었습니다.\n"},"zh":{"lang":"zh","tldr":"提议新增两个 EVM 操作码 SCREDIT 和 SDEBIT，一步完成对存储槽的加法或减法并带溢出检查，为并行 EVM 提供用于余额和计数器的安全原语。","tags":["evm","opcodes","storage","parallel-execution","core"],"related":[2200,2929,1153],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7519/","markdown":"## 它解决什么问题？\n\n许多链，尤其是 Layer 2，都在尝试并行执行交易。常见做法是乐观并发控制：让交易并排运行，再重新运行那些读取被其他交易写入所破坏的交易。但对于最常见的写操作，即更新余额或计数器，这种做法就失效了。两笔触及同一余额的转账总是冲突，尽管\"加 5\"和\"减 3\"可以按任意顺序应用。\n\nEIP-7519 新增了直接表达\"向该槽加值\"和\"从该槽减值\"的操作码。由于 EVM 知道意图，并行引擎只需检查在任何排序下该槽都不会上溢或下溢，而不必检查每次读取是否保持不变。\n\n## 它如何运作\n\n两个操作码，每个都从栈中弹出两项（`slot`、`value`），不压入任何内容。操作码编号在规范中仍为 `TBD`。\n\n| 操作码 | 效果 | 失败条件 |\n| --- | --- | --- |\n| `SCREDIT` | `storage[slot] += value` | 结果将 ≥ 2^256 |\n| `SDEBIT` | `storage[slot] -= value` | 结果将 \u003c 0 |\n\n发生上溢或下溢时，该调用帧会**异常终止**（该帧中的全部 gas 被消耗），不像 `ADD`/`SUB` 那样悄悄回绕。\n\nGas 的收取方式与 **`SSTORE` 完全相同**，包括 [EIP-2929](/eip-2929/) 的 warm/cold 槽规则和 [EIP-2200](/eip-2200/) 的净计量，未来对 `SSTORE` 的任何重新定价也会自动适用。规范认为，额外的工作量（一次加法和一次比较）与存储 I/O 相比可以忽略不计。\n\n只涵盖持久存储。瞬态存储（[EIP-1153](/eip-1153/)）不在其内，因为单笔交易内部不存在并行性。\n\n## 示例代码\n\n该操作码替代了\"加载 / 检查 / 存储\"这一序列。今天在 Solidity 中是这样：\n\n```solidity\n// What SDEBIT(slot, amount) and SCREDIT(slot, amount) do, written with today's opcodes\nmapping(address =\u003e uint256) internal balanceOf;\n\nfunction _transfer(address from, address to, uint256 amount) internal {\n    balanceOf[from] -= amount;   // SLOAD, SUB with underflow check, SSTORE  -\u003e SDEBIT\n    balanceOf[to]   += amount;   // SLOAD, ADD with overflow check,  SSTORE  -\u003e SCREDIT\n}\n```\n\n规范中的执行伪代码，经过精简：\n\n```python\ndef scredit(slot, value):\n    new = storage[slot] + value\n    if new \u003e= 2**256:\n        raise ExceptionalHalt(\"scredit overflow\")\n    storage[slot] = new\n\ndef sdebit(slot, value):\n    new = storage[slot] - value\n    if new \u003c 0:\n        raise ExceptionalHalt(\"sdebit underflow\")\n    storage[slot] = new\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**。这些操作码尚未分配字节值，也没有被排入任何以太坊升级。\n- 规范声明通用的并发原语（锁、信号量）不在范围内；目标是代币余额及类似的计数器。\n- 异常终止会消耗当前调用帧中的全部 gas，比 Solidity 带检查算术的 `revert` 更严厉。调用方应当考虑这一点。\n- 这个新增的失败点是审计人员在推理重入问题时需要考虑的内容。\n- 曾考虑过主要面向 L2，以系统合约而非操作码的方式实现这些操作，但因每次调用所需的代码体积而被否决。\n"}}}
