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

DO NOT REVIEW - MLOAD and MSTORE. #6

Open
wants to merge 1 commit into
base: gas.load
Choose a base branch
from
Open
Changes from all commits
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
20 changes: 17 additions & 3 deletions gas.md
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,13 @@ of the logged registers.
computationCost(MLOAD rREG wINDEX) = mLoadCost + mloadWordCost * memoryCellSize(value wIndex)
estimatedResultSize(MLOAD rREG wINDEX) = memoryCellSize(value wIndex)
```
* `MLOADN`
```hs
computationCost(MLOADN rREG, wINDEX1, wINDEX2, wWIDTH) =
mLoadNCost + mLoadWordCost * wWIDTH
memoryDelta(MLOADN rREG, wINDEX1, wINDEX2, wWIDTH) =
wWIDTH - registerSize rREG
```
* `MSTORE` when we store a new value over an old one, we compute the difference
in size between the two values. Similar to changes to registers, this difference is used to update the
current memory requirements, and, if it increases, it might update the top
Expand All @@ -735,6 +742,15 @@ of the logged registers.
memoryCost(MSTORE wINDEX wVALUE) =
(registerSize wVALUE - storeCellSize(value wIndex))
```
* `MSTOREN`
```hs
computationCost(MSTOREN wINDEX1 wINDEX2 wVALUE wWIDTH) =
mStoreNCost +
mStoreWordCost * max(0, wINDEX2 - storeCellSize(value wIINDEX1))
mStoreWordCost * wWIDTH
memoryDelta(MSTOREN wINDEX1 wINDEX2 wVALUE wWIDTH) =
wWIDTH + max(0, wINDEX2 - storeCellSize(value wIINDEX1))
```

#### Register manipulations
* `MOVE` copies a value from one register to another
Expand Down Expand Up @@ -860,15 +876,13 @@ Definitions
* Check that GMP can give number of limbs in constant time or update costs accordingly
* Check that all background costs are accounted for (e.g. updating a register's)
metadata after an assignment.
* Check that memory deltas are used properly everywhere (e.g. MLOAD).

### TODOS: Instructions to add

* EXTCODESIZE
* CREATE
* SELFDESTRUCT
* INVALID
* MLOADN
* MSTOREN
* COPYCREATE

### TODOS: Instructions to consider if they should be added
Expand Down