{"id":18150308,"url":"https://github.com/jesserc/gevm","last_synced_at":"2025-04-13T23:21:25.147Z","repository":{"id":244446008,"uuid":"815234039","full_name":"Jesserc/gevm","owner":"Jesserc","description":"Isolated EVM, written from scratch, in Go.","archived":false,"fork":false,"pushed_at":"2024-07-10T13:26:51.000Z","size":260,"stargazers_count":100,"open_issues_count":2,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T13:39:25.861Z","etag":null,"topics":["ethereum","evm","golang","virtual-machine"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jesserc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-14T16:39:32.000Z","updated_at":"2025-03-10T07:10:29.000Z","dependencies_parsed_at":"2024-12-17T00:11:33.345Z","dependency_job_id":"246db109-5310-491a-a791-d4c2cfde9aff","html_url":"https://github.com/Jesserc/gevm","commit_stats":null,"previous_names":["jesserc/gevm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jesserc%2Fgevm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jesserc%2Fgevm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jesserc%2Fgevm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jesserc%2Fgevm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jesserc","download_url":"https://codeload.github.com/Jesserc/gevm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248795011,"owners_count":21162701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethereum","evm","golang","virtual-machine"],"created_at":"2024-11-02T00:08:42.401Z","updated_at":"2025-04-13T23:21:25.104Z","avatar_url":"https://github.com/Jesserc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gevm\n\nAn Ethereum Virtual Machine (EVM) implementation from scratch, written in Go.\n\n\u003e [!WARNING]\n\u003e This implementation is for educational purposes and not for production use.\n\nThis project is an isolated EVM implementation, meaning it has no state for accounts. However, memory, storage, and event logs are tracked, although everything resets after each EVM execution.\n\n## Prerequisites\n\n- The Go programming language should be installed: https://go.dev/dl/\n- Ethereum Virtual Machine: https://ethereum.org/en/developers/docs/evm/\n- EVM opcodes: https://www.evm.codes/\n\n## Running the EVM\n\nTo run the EVM:\n\n1. Navigate to the command directory:\n   ```sh\n   cd cmd/gevm\n   ```\n2. Execute the main program:\n\n   ```sh\n   go run main.go\n   ```\n\n   Some simple example bytecodes are provided.\n   There is also an example from an actual compiled contract, which is commented out. Uncomment it to run it.\n   ![alt text](images/image.png)\n\n## Dynamic Gas Calculation\n\nDynamic gas calculation is supported (memory expansion cost and storage operations). Functions for this are located in `gevm/common.go`, and the `dgMap[Opcode]uint64` in `gevm/evm.go` holds records of each opcode that has dynamic gas. The dynamic gas is calculated at runtime for any opcode that has dynamic gas during execution, and the `dgMap` is updated to store this gas cost.\n\n## EVM Structure\n\nThe main EVM files are located in `/gevm`. Here are some key structures:\n\n- `ExecutionRuntime` represents the execution runtime during EVM execution.\n\n  ```go\n  type ExecutionRuntime struct {\n      PC         uint64\n      Code       []byte\n      Gas        uint64\n      Refund     uint64\n      StopFlag   bool\n      RevertFlag bool\n      ReturnData []byte\n      LogRecord  *LogRecord\n      Block      *Block\n  }\n  ```\n\n- `ExecutionEnvironment` encapsulates the EVM execution data environment, including the stack, memory, storage, and transient storage.\n\n  ```go\n  type ExecutionEnvironment struct {\n      Stack     *Stack\n      Memory    *Memory\n      Storage   *Storage\n      Transient *TransientStorage\n  }\n  ```\n\n- `TransactionContext` holds transaction-specific information during EVM execution.\n\n  ```go\n  type TransactionContext struct {\n      Sender   common.Address\n      Value    uint64\n      Calldata []byte\n  }\n  ```\n\n- `ChainConfig` stores network configuration parameters.\n\n  ```go\n  type ChainConfig struct {\n      ChainID  uint64\n      GasLimit uint64\n  }\n  ```\n\n- `Block` represents a block.\n  ```go\n  type Block struct {\n      Coinbase  common.Address\n      GasPrice  uint64\n      Number    uint64\n      Timestamp time.Time\n      BaseFee   uint64\n  }\n  ```\n\nAll these are initialized with the `NewEVM` function found in `gevm/evm.go`.\n\n## Tests\n\nTo run unit tests:\n\n```sh\ngo test -v\n```\n\nFor a better understanding of the project, explore the files in `/gevm`.\n\n## Supported Opcodes\n\nThe implementation supports 131 out of the 143 EVM opcodes.\n\n## Unsupported Opcodes\n\nThe following opcodes are not supported:\n\n- CREATE\n- CALL\n- CALLCODE\n- DELEGATECALL\n- CREATE2\n- EXTCODEHASH\n- DIFFICULTY\n- STATICCALL\n- SELFBALANCE\n- SELFDESTRUCT\n- EIP-4844 opcodes: BLOBHASH, BLOBBASEFEE\n\nThese opcodes typically require state management. All other opcodes are supported, including EIP-1153 transient storage opcodes `TLOAD` and `TSTORE`.\n\n## Resources\n\n- EVM opcodes (highly recommended, has accurate gas costs for opcodes): https://www.evm.codes/\n- EVM from scratch book: https://evm-from-scratch.xyz/\n\n## Contributing\n\nContributions are welcome! Please feel free to create an issue or submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesserc%2Fgevm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjesserc%2Fgevm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesserc%2Fgevm/lists"}