Skip to content

Commit

Permalink
remove internalcalldepth instr
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanks12 committed Jan 18, 2024
1 parent ca5ce3a commit 2bb5543
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 71 deletions.
85 changes: 30 additions & 55 deletions yellow-paper/docs/public-vm/gen/_InstructionSet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -327,103 +327,95 @@ context.machineState.pc = loc`}
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x27</td> <td style={{'text-align': 'center'}}><a id='isa-table-internalcalldepth'/><Markdown>[`INTERNALCALLDEPTH`](#isa-section-internalcalldepth)</Markdown></td>
<td><Markdown>Get the depth of the current context's internal call stack</Markdown></td>
<td><Markdown>56</Markdown></td>
<td><CodeBlock language="jsx">{
`M[dstOffset] = context.machineState.internalCallStack.length`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x28</td> <td style={{'text-align': 'center'}}><a id='isa-table-set'/><Markdown>[`SET`](#isa-section-set)</Markdown></td>
<td style={{'text-align': 'center'}}>0x27</td> <td style={{'text-align': 'center'}}><a id='isa-table-set'/><Markdown>[`SET`](#isa-section-set)</Markdown></td>
<td><Markdown>Set a memory word from a constant in the bytecode</Markdown></td>
<td><Markdown>64+N</Markdown></td>
<td><CodeBlock language="jsx">{
`M[dstOffset] = const`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x29</td> <td style={{'text-align': 'center'}}><a id='isa-table-mov'/><Markdown>[`MOV`](#isa-section-mov)</Markdown></td>
<td style={{'text-align': 'center'}}>0x28</td> <td style={{'text-align': 'center'}}><a id='isa-table-mov'/><Markdown>[`MOV`](#isa-section-mov)</Markdown></td>
<td><Markdown>Move a word from source memory location to destination</Markdown></td>
<td><Markdown>88</Markdown></td>
<td><CodeBlock language="jsx">{
`M[dstOffset] = M[srcOffset]`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x2a</td> <td style={{'text-align': 'center'}}><a id='isa-table-cmov'/><Markdown>[`CMOV`](#isa-section-cmov)</Markdown></td>
<td style={{'text-align': 'center'}}>0x29</td> <td style={{'text-align': 'center'}}><a id='isa-table-cmov'/><Markdown>[`CMOV`](#isa-section-cmov)</Markdown></td>
<td><Markdown>Move a word (conditionally chosen) from one memory location to another (`d = cond &gt; 0 ? a : b`)</Markdown></td>
<td><Markdown>152</Markdown></td>
<td><CodeBlock language="jsx">{
`M[dstOffset] = M[condOffset] > 0 ? M[aOffset] : M[bOffset]`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x2b</td> <td style={{'text-align': 'center'}}><a id='isa-table-blockheaderbynum'/><Markdown>[`BLOCKHEADERBYNUM`](#isa-section-blockheaderbynum)</Markdown></td>
<td style={{'text-align': 'center'}}>0x2a</td> <td style={{'text-align': 'center'}}><a id='isa-table-blockheaderbynum'/><Markdown>[`BLOCKHEADERBYNUM`](#isa-section-blockheaderbynum)</Markdown></td>
<td><Markdown>Get the block header as of the specified block number</Markdown></td>
<td><Markdown>88</Markdown></td>
<td><CodeBlock language="jsx">{
`M[dstOffset:dstOffset+BLOCK_HEADER_LENGTH] = context.worldState.blockHeader[M[blockNumOffset]]`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x2c</td> <td style={{'text-align': 'center'}}><a id='isa-table-sload'/><Markdown>[`SLOAD`](#isa-section-sload)</Markdown></td>
<td style={{'text-align': 'center'}}>0x2b</td> <td style={{'text-align': 'center'}}><a id='isa-table-sload'/><Markdown>[`SLOAD`](#isa-section-sload)</Markdown></td>
<td><Markdown>Load a word from storage</Markdown></td>
<td><Markdown>88</Markdown></td>
<td><CodeBlock language="jsx">{
`M[dstOffset] = context.worldState.publicStorage[context.environment.storageAddress, M[slotOffset]]`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x2d</td> <td style={{'text-align': 'center'}}><a id='isa-table-sstore'/><Markdown>[`SSTORE`](#isa-section-sstore)</Markdown></td>
<td style={{'text-align': 'center'}}>0x2c</td> <td style={{'text-align': 'center'}}><a id='isa-table-sstore'/><Markdown>[`SSTORE`](#isa-section-sstore)</Markdown></td>
<td><Markdown>Write a word to storage</Markdown></td>
<td><Markdown>88</Markdown></td>
<td><CodeBlock language="jsx">{
`context.worldState.publicStorage[context.environment.storageAddress, M[slotOffset]] = M[srcOffset]`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x2e</td> <td style={{'text-align': 'center'}}><a id='isa-table-readl1tol2msg'/><Markdown>[`READL1TOL2MSG`](#isa-section-readl1tol2msg)</Markdown></td>
<td style={{'text-align': 'center'}}>0x2d</td> <td style={{'text-align': 'center'}}><a id='isa-table-readl1tol2msg'/><Markdown>[`READL1TOL2MSG`](#isa-section-readl1tol2msg)</Markdown></td>
<td><Markdown>Reads an L1-to-L2 message</Markdown></td>
<td><Markdown>120</Markdown></td>
<td><CodeBlock language="jsx">{
`M[dstOffset:dstOffset+msgSize] = context.worldState.l1ToL2Messages(M[msgKeyOffset])`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x2f</td> <td style={{'text-align': 'center'}}><a id='isa-table-sendl2tol1msg'/><Markdown>[`SENDL2TOL1MSG`](#isa-section-sendl2tol1msg)</Markdown></td>
<td style={{'text-align': 'center'}}>0x2e</td> <td style={{'text-align': 'center'}}><a id='isa-table-sendl2tol1msg'/><Markdown>[`SENDL2TOL1MSG`](#isa-section-sendl2tol1msg)</Markdown></td>
<td><Markdown>Send an L2-to-L1 message</Markdown></td>
<td><Markdown>88</Markdown></td>
<td><CodeBlock language="jsx">{
`context.worldState.l2ToL1Messages.append(M[msgOffset:msgOffset+msgSize])`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x30</td> <td style={{'text-align': 'center'}}><a id='isa-table-emitnotehash'/><Markdown>[`EMITNOTEHASH`](#isa-section-emitnotehash)</Markdown></td>
<td style={{'text-align': 'center'}}>0x2f</td> <td style={{'text-align': 'center'}}><a id='isa-table-emitnotehash'/><Markdown>[`EMITNOTEHASH`](#isa-section-emitnotehash)</Markdown></td>
<td><Markdown>Emit a new note hash to be inserted into the notes tree</Markdown></td>
<td><Markdown>56</Markdown></td>
<td><CodeBlock language="jsx">{
`context.worldState.newHashes.append(M[noteHashOffset])`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x31</td> <td style={{'text-align': 'center'}}><a id='isa-table-emitnullifier'/><Markdown>[`EMITNULLIFIER`](#isa-section-emitnullifier)</Markdown></td>
<td style={{'text-align': 'center'}}>0x30</td> <td style={{'text-align': 'center'}}><a id='isa-table-emitnullifier'/><Markdown>[`EMITNULLIFIER`](#isa-section-emitnullifier)</Markdown></td>
<td><Markdown>Emit a new nullifier to be inserted into the nullifier tree</Markdown></td>
<td><Markdown>56</Markdown></td>
<td><CodeBlock language="jsx">{
`context.worldState.nullifiers.append(M[nullifierOffset])`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x32</td> <td style={{'text-align': 'center'}}><a id='isa-table-emitunencryptedlog'/><Markdown>[`EMITUNENCRYPTEDLOG`](#isa-section-emitunencryptedlog)</Markdown></td>
<td style={{'text-align': 'center'}}>0x31</td> <td style={{'text-align': 'center'}}><a id='isa-table-emitunencryptedlog'/><Markdown>[`EMITUNENCRYPTEDLOG`](#isa-section-emitunencryptedlog)</Markdown></td>
<td><Markdown>Emit an unencrypted log</Markdown></td>
<td><Markdown>88</Markdown></td>
<td><CodeBlock language="jsx">{
`context.accruedSubstate.unencryptedLogs.append(M[logOffset:logOffset+logSize])`
}</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x33</td> <td style={{'text-align': 'center'}}><a id='isa-table-call'/><Markdown>[`CALL`](#isa-section-call)</Markdown></td>
<td style={{'text-align': 'center'}}>0x32</td> <td style={{'text-align': 'center'}}><a id='isa-table-call'/><Markdown>[`CALL`](#isa-section-call)</Markdown></td>
<td><Markdown>Call into another contract</Markdown></td>
<td><Markdown>248</Markdown></td>
<td><CodeBlock language="jsx">
Expand All @@ -435,7 +427,7 @@ context.machineState.pc = loc`}
</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x34</td> <td style={{'text-align': 'center'}}><a id='isa-table-staticcall'/><Markdown>[`STATICCALL`](#isa-section-staticcall)</Markdown></td>
<td style={{'text-align': 'center'}}>0x33</td> <td style={{'text-align': 'center'}}><a id='isa-table-staticcall'/><Markdown>[`STATICCALL`](#isa-section-staticcall)</Markdown></td>
<td><Markdown>Call into another contract, disallowing World State and Accrued Substate modifications</Markdown></td>
<td><Markdown>248</Markdown></td>
<td><CodeBlock language="jsx">
Expand All @@ -447,7 +439,7 @@ context.machineState.pc = loc`}
</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x35</td> <td style={{'text-align': 'center'}}><a id='isa-table-return'/><Markdown>[`RETURN`](#isa-section-return)</Markdown></td>
<td style={{'text-align': 'center'}}>0x34</td> <td style={{'text-align': 'center'}}><a id='isa-table-return'/><Markdown>[`RETURN`](#isa-section-return)</Markdown></td>
<td><Markdown>Halt execution within this context (without revert), optionally returning some data</Markdown></td>
<td><Markdown>88</Markdown></td>
<td><CodeBlock language="jsx">
Expand All @@ -456,7 +448,7 @@ halt`}
</CodeBlock></td>
</tr>
<tr>
<td style={{'text-align': 'center'}}>0x36</td> <td style={{'text-align': 'center'}}><a id='isa-table-revert'/><Markdown>[`REVERT`](#isa-section-revert)</Markdown></td>
<td style={{'text-align': 'center'}}>0x35</td> <td style={{'text-align': 'center'}}><a id='isa-table-revert'/><Markdown>[`REVERT`](#isa-section-revert)</Markdown></td>
<td><Markdown>Halt execution within this context as `reverted`, optionally returning some data</Markdown></td>
<td><Markdown>88</Markdown></td>
<td><CodeBlock language="jsx">
Expand Down Expand Up @@ -1187,29 +1179,12 @@ Return from an internal call. Pop from the internal call stack and jump to the p

[![](./images/bit-formats/INTERNALRETURN.png)](./images/bit-formats/INTERNALRETURN.png)

### <a id='isa-section-internalcalldepth'/>`INTERNALCALLDEPTH`
Get the depth of the current context's internal call stack

[See in table.](#isa-table-internalcalldepth)

- **Opcode**: 0x27
- **Category**: Machine State - Control Flow
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
- **Args**:
- **dstOffset**: memory offset specifying where to store operation's result
- **Expression**: `M[dstOffset] = context.machineState.internalCallStack.length`
- **Tag updates**: `T[dstOffset] = u32`
- **Bit-size**: 56

[![](./images/bit-formats/INTERNALCALLDEPTH.png)](./images/bit-formats/INTERNALCALLDEPTH.png)

### <a id='isa-section-set'/>`SET`
Set a memory word from a constant in the bytecode

[See in table.](#isa-table-set)

- **Opcode**: 0x28
- **Opcode**: 0x27
- **Category**: Machine State - Memory
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1229,7 +1204,7 @@ Move a word from source memory location to destination

[See in table.](#isa-table-mov)

- **Opcode**: 0x29
- **Opcode**: 0x28
- **Category**: Machine State - Memory
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1247,7 +1222,7 @@ Move a word (conditionally chosen) from one memory location to another (`d = con

[See in table.](#isa-table-cmov)

- **Opcode**: 0x2a
- **Opcode**: 0x29
- **Category**: Machine State - Memory
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1268,7 +1243,7 @@ Get the block header as of the specified block number

[See in table.](#isa-table-blockheaderbynum)

- **Opcode**: 0x2b
- **Opcode**: 0x2a
- **Category**: World State
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1286,7 +1261,7 @@ Load a word from storage

[See in table.](#isa-table-sload)

- **Opcode**: 0x2c
- **Opcode**: 0x2b
- **Category**: World State - Public Storage
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1305,7 +1280,7 @@ Write a word to storage

[See in table.](#isa-table-sstore)

- **Opcode**: 0x2d
- **Opcode**: 0x2c
- **Category**: World State - Public Storage
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1323,7 +1298,7 @@ Reads an L1-to-L2 message

[See in table.](#isa-table-readl1tol2msg)

- **Opcode**: 0x2e
- **Opcode**: 0x2d
- **Category**: World State - Messaging
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1342,7 +1317,7 @@ Send an L2-to-L1 message

[See in table.](#isa-table-sendl2tol1msg)

- **Opcode**: 0x2f
- **Opcode**: 0x2e
- **Category**: World State - Messaging
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1359,7 +1334,7 @@ Emit a new note hash to be inserted into the notes tree

[See in table.](#isa-table-emitnotehash)

- **Opcode**: 0x30
- **Opcode**: 0x2f
- **Category**: World State - Notes & Nullifiers
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1375,7 +1350,7 @@ Emit a new nullifier to be inserted into the nullifier tree

[See in table.](#isa-table-emitnullifier)

- **Opcode**: 0x31
- **Opcode**: 0x30
- **Category**: World State - Notes & Nullifiers
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1391,7 +1366,7 @@ Emit an unencrypted log

[See in table.](#isa-table-emitunencryptedlog)

- **Opcode**: 0x32
- **Opcode**: 0x31
- **Category**: Accrued Substate - Logging
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1408,7 +1383,7 @@ Call into another contract

[See in table.](#isa-table-call)

- **Opcode**: 0x33
- **Opcode**: 0x32
- **Category**: Control Flow - Contract Calls
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand Down Expand Up @@ -1446,7 +1421,7 @@ Call into another contract, disallowing World State and Accrued Substate modific

[See in table.](#isa-table-staticcall)

- **Opcode**: 0x34
- **Opcode**: 0x33
- **Category**: Control Flow - Contract Calls
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand Down Expand Up @@ -1482,7 +1457,7 @@ Halt execution within this context (without revert), optionally returning some d

[See in table.](#isa-table-return)

- **Opcode**: 0x35
- **Opcode**: 0x34
- **Category**: Control Flow - Contract Calls
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand All @@ -1504,7 +1479,7 @@ Halt execution within this context as `reverted`, optionally returning some data

[See in table.](#isa-table-revert)

- **Opcode**: 0x36
- **Opcode**: 0x35
- **Category**: Control Flow - Contract Calls
- **Flags**:
- **indirect**: Toggles whether each memory-offset argument is an indirect offset. 0th bit corresponds to 0th offset arg, etc. Indirect offsets result in memory accesses like `M[M[offset]]` instead of the more standard `M[offset]`.
Expand Down
Binary file not shown.
16 changes: 0 additions & 16 deletions yellow-paper/src/preprocess/InstructionSet/InstructionSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,22 +674,6 @@ context.machineState.pc = loc
"Tag checks": "",
"Tag updates": "",
},
{
"id": "internalcalldepth",
"Name": "`INTERNALCALLDEPTH`",
"Category": "Machine State - Control Flow",
"Flags": [
{"name": "indirect", "description": INDIRECT_FLAG_DESCRIPTION},
],
"Args": [
{"name": "dstOffset", "description": "memory offset specifying where to store operation's result"},
],
"Expression": "`M[dstOffset] = context.machineState.internalCallStack.length`",
"Summary": "Get the depth of the current context's internal call stack",
"Details": "",
"Tag checks": "",
"Tag updates": "`T[dstOffset] = u32`",
},
{
"id": "set",
"Name": "`SET`",
Expand Down

0 comments on commit 2bb5543

Please sign in to comment.