Skip to content
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

SET_INDESTRUCTIBLE opcode #2937

Merged
merged 8 commits into from
Sep 10, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
SET_INDESTRUCTIBLE opcode
Add a `SET_INDESTRUCTIBLE` opcode that prevents the contract from calling `SELFDESTRUCT`.
  • Loading branch information
vbuterin authored Sep 4, 2020
commit ecf2c8f75d8638734f182753a661219d0ee311f9
35 changes: 35 additions & 0 deletions EIPS/eip-2937.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
eip: 2937
title: SET_INDESTRUCTIBLE opcode
author: Vitalik Buterin (@vbuterin)
discussions-to: <URL>
status: Draft
type: Standards Track
category: Core
created: 2020-09-04
---

## Simple Summary

Add a `SET_INDESTRUCTIBLE (0xA8)` opcode that prevents the contract from calling `SELFDESTRUCT (0xff)`.

## Specification

Add a context-wide variable `locals.indestructible` (ie. a variable that lives in the same "space" as memory, stack, PC...), initialized to `False`.

Add a `SET_INDESTRUCTIBLE` opcode at `0xA8`, with gas cost 2 (`G_base`) , that sets `locals.indestructible` to `True`. If in the current execution context `locals.indestructible` is `True`, the `SELFDESTRUCT` opcode throws an exception.

## Motivation

The intended use case would be for contracts to make their first byte of code be the `SET_INDESTRUCTIBLE` opcode if they wish to serve as libraries that guarantee to users that their code will exist unmodified forever. This is useful in account abstraction as well as other contexts.

Unlike EIPs that disable the `SELFDESTRUCT` opcode entirely, this EIP does not modify behavior of any existing contracts.

## Forwards Compatibility and Security

This breaks forward compatibility with _some_ forms of state rent, which would simply delete contracts that get too old without paying some maintenance fee. However, this is not the case with all state size control schemes; for example this is not an issue if we use [ReGenesis](https://ledgerwatch.github.io/regenesis_plan.html).

If `SELFDESTRUCT` is ever removed in the future, this EIP would simply become a no-op.
Comment on lines +43 to +45
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not personally a fan of forward compatibility stuff in an EIP. This feels like something much more appropriate in the discussion-to link, or in the HF inclusion discussions. If you imagine reading this EIP 5 years in the future after it has been implemented, this section won't really provide any significant value to those readers.


## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).