Skip to content

Commit

Permalink
Merge pull request #9 from shafu0x/transient
Browse files Browse the repository at this point in the history
tstore/tload
  • Loading branch information
shafu0x authored Mar 13, 2024
2 parents dbe7e1c + 27602ce commit da20a3c
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
19 changes: 19 additions & 0 deletions content/07_opcodes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,25 @@
"JUMPDEST = 0x5B"
]
},
{
"cell_type": "markdown",
"id": "72207b23",
"metadata": {},
"source": [
"## Transient Storage"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2c779167",
"metadata": {},
"outputs": [],
"source": [
"TLOAD = 0x5c\n",
"TSTORE = 0x5d"
]
},
{
"cell_type": "markdown",
"id": "5f4b87bb",
Expand Down
87 changes: 87 additions & 0 deletions content/07a_opcodes/transient.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "9e99987a",
"metadata": {},
"source": [
"# Transient Storage"
]
},
{
"cell_type": "markdown",
"id": "b1506617",
"metadata": {},
"source": [
"These opcodes behave almostidentically to storage but changes are discarded after every transaction."
]
},
{
"cell_type": "markdown",
"id": "3027a9a9",
"metadata": {},
"source": [
"#### Transient Storage Load"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b0010cdd",
"metadata": {},
"outputs": [],
"source": [
"def tload(evm): \n",
" key = evm.stack.pop().value\n",
" warm, value = evm.storage.load(key)\n",
" evm.stack.push(value)\n",
"\n",
" evm.gas_dec(100)\n",
" evm.pc += 1"
]
},
{
"cell_type": "markdown",
"id": "1a2422b7",
"metadata": {},
"source": [
"#### Transient Storage Store"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c7032489",
"metadata": {},
"outputs": [],
"source": [
"def tstore(evm): \n",
" key, value = evm.stack.pop(), evm.stack.pop()\n",
" evm.storage.store(key, value)\n",
" evm.gas_dec(100)\n",
" evm.pc += 1"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit da20a3c

Please sign in to comment.