This commit is contained in:
osiris account 2023-03-15 11:02:04 -07:00
parent 982078a66c
commit 98e5bd2cce
8 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,36 @@
## the evm
### tl;dr
* EVM is a quasi-Turing complete machine (quasi because computation is intrinsically bounded/limited through a parameter: gas)
* EVM is the runtime environment for smart contracts.
* "Ethereum virtual machine code" or "EVM code" are cute lil code are written in a low-level, stack-based bytecode language, each byte represents an operation.
* EVM memory is a simple stack-based architecture with: stack, volatile memory, non-volatile storage (word size of 256-bit) and the fearful Calldata.
<br>
---
### in this repo
<br>
* [my favorite opcodes](evm_and_opcodes/my_favorite_opcodes.md)
<br>
---
### resources
<br>
* [opcodes for the evm](https://ethereum.org/en/developers/docs/evm/opcodes/)
* [opcodes and instruction reference](https://github.com/crytic/evm-opcodes)
* [EVM Contract Construction](https://blog.smlxl.io/evm-contract-construction-93c98cc4ca96)
* [ethersplay](https://github.com/crytic/ethersplay)
* [IDA EVM](https://github.com/crytic/ida-evm)
* [Ethereum book](https://github.com/ethereumbook/ethereumbook)
* [Ethereum's Whitepaper](https://ethereum.org/en/whitepaper/)
* [Understanding rollups](https://barnabe.substack.com/p/understanding-rollup-economics-from?s=r)

View file

@ -0,0 +1,21 @@
## 🐼 my favorite opcodes
<br>
| opocde | name | min gas | details |
| ----------- | ----------- | ----------- | --------------- |
| 20 | SAH3 | 30 | keccak-256 hash of the given data in memory |
| 31 | BALANCE | 100 | balance of a given 20-byte address in wei |
| 33 | CALLER | 33 | the 20-byte address of the last caller account (except delegate call) |
| 3A | GASPRICE | 2 | gas price in wei per gas |
| 40 | BLOCKHASH | 20 | hash of the chosen block, or 0 if the block is not the valid range |
| ~☠44🪦~ | DIFFICULT | 😵 | current block difficulty |
| 45 | GASLIIT | 2 | get gas limit |
| 48 | BASEFEE | 2 | get base fee in wei |
| 5A | GAS | 2 | remaining gas after instructions |
| F0 | CREATE2 | 32000 | create a new contract - the new account's code is set to the return data resulting from executing the inialisation code - the destination address is calculated as `initialisation_code = memory[offset:offset+size]` and `address = keccak256(0xff + sender_address + salt + keccak256(initialisation_code))[12:]` |
| F1 | CALL | 100 | create a new sub context and execute the code of the given account, then resumes the current one |
| F2 | CALLCODE | 100 | create a new sub context and execute the code of the given account - the storage remains the same |
| F4 | ✨DELEGATECALL✨ | 100 | create a new sub context and execute the code of the given account - the storage, the current sender, and the current value remain the same |
| FA | STATICCALL | 100 | create a new sub context and execute the code of the given account, then resumes the current one - equivalent to CALL, except that it does not allow any state modifying instructions or sending ETH in the sub context |
| FF | SELFDESTRUCT | 5000 | the new account is registered to be destroyed at the end of the current transaction |