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

Update EIP-101: Move to Draft #9199

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
Prev Previous commit
Next Next commit
Fix markdown linting issues and update EIP-101
  • Loading branch information
irfand29 committed Dec 28, 2024
commit d77353726247a3090ca0ee50c1f23b97bd20fe33
37 changes: 37 additions & 0 deletions EIPS/eip-101.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# EIP-101: Serenity Currency and Crypto Abstraction

### Specification

1. Accounts now have only two fields in their RLP encoding: code and storage.
2. Ether is no longer stored in account objects directly. Instead, a contract is premine at address 0 to store all ether holdings, and the `eth.getBalance` command in Web3 is now remapped to interact with this contract.
3. The `msg.value` opcode is no longer available in this new model.
4. A transaction now consists of four fields: `to`, `startgas`, `data`, and `code`. The `startgas` field specifies the initial gas allocated for the transaction.
5. Aside from validating the RLP encoding, the following checks are made:
- The `to` field is 20 bytes long.
- `startgas` is an integer.
- `code` is either empty or hashes to the `to` address. Other than these checks, the transaction is valid; however, block gas limits apply.
6. Gas is charged for bytes in `code` at the same rate as data.
7. When a transaction is sent, if the receiving account does not exist, it is created, and its code is set to the code specified in the transaction. If the account already exists, the provided code is ignored.
8. A `tx.gas` opcode is introduced alongside the existing `msg.gas` at index `0x5c`. This allows a transaction to reference the original gas allocation set for it, providing more control over gas usage.

### Default Code for Simple User Accounts

Simple user accounts may have the following default code to implement signature and nonce checking:

```python
# We assume the data schema is as follows:
# bytes 0-31: v (ECDSA sig)
# bytes 32-63: r (ECDSA sig)
# bytes 64-95: s (ECDSA sig)
# bytes 96-127: sequence number (formerly nonce)
# bytes 128-159: gas price
# bytes 172-191: to address
# bytes 192+: data

# Get the transaction hash for signing
~mstore(0, msg.gas)
~calldatacopy(32, 96, ~calldatasize() - 96)
h = sha3(96, ~calldatasize() - 96)

# Retrieve the sender address using ECRECOVER
~call(5000, 3, [h, ~calldataload(0), ~calldataload(32), ~calldataload(64)], 128, ref(addr), 32)
---
eip: 101
title: Serenity Currency and Crypto Abstraction
Expand Down