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

Yellow paper configuration #9

Merged
merged 77 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
f3e875d
Docker env and CGBN/GMP libraries (256-integer)
sdcioc Oct 26, 2023
f8c7577
stack functions implmentation and opcodes for evm
sdcioc Oct 29, 2023
c3f89f6
block/message/storage
sdcioc Oct 30, 2023
d2d8553
message and return data basic implementation
sdcioc Oct 30, 2023
ed29db2
memory implementation fixed and dynamic
sdcioc Nov 1, 2023
af9fd97
block/local storage/global storage/ message
sdcioc Nov 2, 2023
fb7a25d
alpha version of interpreter
sdcioc Nov 3, 2023
7cd82bb
adding cjson and separete evm
sdcioc Nov 6, 2023
728e21d
block and message json
sdcioc Nov 6, 2023
6a3619c
block and message cpu/gpu + json
sdcioc Nov 7, 2023
4b212f3
memory addition
sdcioc Nov 7, 2023
0deb6e4
memory with gas done
sdcioc Nov 8, 2023
848e909
stack update
sdcioc Nov 8, 2023
a672ce2
evm update
sdcioc Nov 13, 2023
3b15333
arithmetic interpreter done
sdcioc Nov 14, 2023
a085d72
cpu/gpu interpreter with multiple tests
sdcioc Nov 14, 2023
0759b89
keccak test
sdcioc Nov 20, 2023
284ccd7
keccak add to interpreter
sdcioc Nov 21, 2023
6b7789b
test new storage heirarchy
sdcioc Nov 22, 2023
6a72a3e
patch the length of json string values
sdcioc Nov 22, 2023
c23a72e
address fix to json
sdcioc Nov 23, 2023
aa3c619
new return data
sdcioc Nov 23, 2023
03ff65a
cross contract calls
sdcioc Nov 23, 2023
ea3aa38
add revmi and pass arithmetic tests
sdcioc Nov 27, 2023
3fdcd06
cuda memory fix
sdcioc Nov 28, 2023
a5c7484
memory refactor for special cases
sdcioc Dec 1, 2023
24c0763
memmory free fix
sdcioc Dec 1, 2023
759e839
add initial transaction cost
sdcioc Dec 1, 2023
ecb30ce
pass most of the test. gpu problems with gas.
sdcioc Dec 3, 2023
4060739
fix keccak memory on gpu. write_state still
sdcioc Dec 3, 2023
f6a83ea
destination jumps fix
sdcioc Dec 4, 2023
bf71a61
files cleaning
sdcioc Dec 5, 2023
6921601
add gas cost and new state architecture
sdcioc Dec 5, 2023
e7f8451
access state
sdcioc Dec 6, 2023
bb09255
new states architecture
sdcioc Dec 7, 2023
55ddb7c
state update, block, jump_d doc
sdcioc Dec 8, 2023
905918b
block and keccak
sdcioc Dec 8, 2023
f356899
memory doc and test
sdcioc Dec 10, 2023
b487278
separate transaction and call message
sdcioc Dec 11, 2023
9aeaf86
components ready and tracer done
sdcioc Dec 12, 2023
934d518
trasnsaction update
sdcioc Dec 13, 2023
90747da
operation modules
sdcioc Dec 14, 2023
5ccc83e
alu, env, internal operations implementation and documentation
sdcioc Dec 15, 2023
355adb8
testing the modules and preliminary new evm
sdcioc Dec 16, 2023
e61cb77
less demanding tracer and bug fix
sdcioc Dec 18, 2023
f25e61e
return bug fix when no code
sdcioc Dec 19, 2023
cae856e
log initial implementation
sdcioc Dec 19, 2023
a9a7bb1
LOGX implemented and fix gpu tracer copy
sdcioc Dec 20, 2023
ed480d0
add create2
sdcioc Dec 21, 2023
4b37b99
CREATEX operations
sdcioc Dec 23, 2023
c791dc4
CREATE adress and initcode cost fix
sdcioc Dec 26, 2023
16cc6fb
docs
sdcioc Dec 26, 2023
8c21b35
github actions documentation
sdcioc Dec 27, 2023
1673421
caching the packages
sdcioc Dec 27, 2023
1e37243
requirements fix
sdcioc Dec 27, 2023
ffa15dc
new cmake list with options and docs github actions
sdcioc Dec 27, 2023
5a57478
new choice for github actions
sdcioc Dec 27, 2023
8ef9b35
repair name container
sdcioc Dec 27, 2023
856407e
try feature
sdcioc Dec 27, 2023
a26560c
test container
sdcioc Dec 27, 2023
3398fd4
try fix
sdcioc Dec 27, 2023
9dbb22b
docker login
sdcioc Dec 27, 2023
7ca1c82
dix yaml docs.yml
sdcioc Dec 27, 2023
e1cf598
fix apt cache
sdcioc Dec 27, 2023
7d9a13a
fix apt name
sdcioc Dec 27, 2023
d4a2c20
take out sudo
sdcioc Dec 27, 2023
b1c4043
setup TZ
sdcioc Dec 27, 2023
a60c433
another TZ fix
sdcioc Dec 27, 2023
738d805
another try
sdcioc Dec 27, 2023
d273849
take out workspace
sdcioc Dec 27, 2023
a601e6e
no timedatectl
sdcioc Dec 27, 2023
00f0894
another fix
sdcioc Dec 27, 2023
a07667b
test pages
sdcioc Dec 27, 2023
bd40569
wrtie permission for token
sdcioc Dec 27, 2023
7c76d8b
ARTIFICAT FIX
sdcioc Dec 27, 2023
1b6f731
update README and child call
sdcioc Dec 28, 2023
a842f4f
Merge branch 'main' into yellow_paper
sdcioc Dec 28, 2023
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
24 changes: 24 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM nvidia/cuda:12.0.0-devel-ubuntu22.04

# LABEL about the custom image
LABEL maintainer="[email protected]"
LABEL version="0.1"
LABEL description="This is a custom Docker Image for CuEVM project"

# Disable Prompt During Packages Installation
ARG DEBIAN_FRONTEND=noninteractive
# display
ENV DISPLAY=host.docker.internal:0.0
# timezone
ENV TZ=Asia/Singapore
# Update Ubuntu Software repository
# necasry tools curl zip unzip git wget
# gmp libgmp-dev
# cjson libcjson1 libcjson-dev
# clang
# valgrind
RUN apt-get update && apt-get upgrade -y && apt-get install -y locales && locale-gen "en_US.UTF-8" && dpkg-reconfigure locales && apt-get install -y curl zip unzip git wget libgmp-dev libcjson1 libcjson-dev libclang-dev valgrind clang-format
# install rustup for REVMI
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o sh.rustup.rs && sh sh.rustup.rs -y && rm sh.rustup.rs
# install tools for documentation
RUN apt-get update && apt-get install -y doxygen sphinx cmake python3-pip && pip3 install breathe exhale sphinx_rtd_theme sphinx_book_theme
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "QLE dev container",
"build": { "dockerfile": "Dockerfile" },
"runArgs": [
"--rm", "--gpus=all"
],
//"remoteEnv": {
// "ENV_VAR": "ENV_VAL"
//},
"customizations": {
"vscode": {
"extensions": [
"GitHub.vscode-pull-request-github",
"GitHub.copilot",
"ms-vscode.makefile-tools",
"NVIDIA.nsight-vscode-edition",
"ms-vscode.cpptools-extension-pack",
"ccimage.jsonviewer",
"xaver.clang-format"
]
}
}//,
//"postStartCommand": ""
}
77 changes: 77 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Docs

on:
#push:
# branches-ignore:
# - '**'
push:
branches: [ yellow_paper ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-22.04
container:
image: nvidia/cuda:12.0.0-devel-ubuntu22.04
credentials:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
env:
DEBIAN_FRONTEND: "noninteractive"
TZ: "Asia/Singapore"

steps:
- name: Checkout
uses: actions/[email protected]
- name: Apt Requirements
run: DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y doxygen sphinx cmake python3-pip libgmp-dev libcjson1 libcjson-dev git
- name: Pip3 Requirements
run: pip3 install -r docs/requirements.txt
- name: Configure CMake
run: cmake -S . -B build -G "Unix Makefiles" -DWITH_DOCS=ON
- name: Build docs
run: cmake --build build --target docs
- name: Upload page artficat
uses: actions/upload-artifact@v4
with:
name: cuevm-docs-artifact
path: build/docs/docs/sphinx/

deploy:
runs-on: ubuntu-22.04
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Download artficat
uses: actions/download-artifact@v4
with:
name: cuevm-docs-artifact
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,17 @@
*.ptx
*.cubin
*.fatbin

# binaries
/out
/input
/output


build/
_build/
_static/
_templates/
docs/api/
*.o
cuEVM
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "CGBN"]
path = CGBN
url = https://github.com/NVlabs/CGBN.git
[submodule "REVMI"]
path = REVMI
url = https://github.com/cassc/evm_interpreter.git
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "CUDA C++: Launch",
"type": "cuda-gdb",
"request": "launch",
"program": "${workspaceFolder}/out/interpreter",
"args": "--input ${workspaceFolder}/input/evm_test.json --output ${workspaceFolder}/output/evm_test.json",
},
{
"name": "CUDA C++: Attach",
"type": "cuda-gdb",
"request": "attach"
}
]
}
22 changes: 21 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
"files.associations": {
"*.ejs": "html",
"iostream": "cpp",
"string_view": "cpp"
"string_view": "cpp",
"random": "cpp",
"chrono": "cpp",
"algorithm": "cpp",
"*.tcc": "cpp",
"string": "cpp",
"functional": "cpp",
"ratio": "cpp",
"system_error": "cpp",
"array": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"limits": "cpp",
"initializer_list": "cpp",
"memory": "cpp",
"stdlib.h": "c",
"typeinfo": "cpp",
"cstdint": "cpp",
"vector": "cpp",
"atomic": "cpp"
}
}
1 change: 1 addition & 0 deletions CGBN
Submodule CGBN added at e8b9d2
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
option(WITH_COMPILE "Doing the nvcc compilation" OFF)
option(WITH_DOCS "Geenrating the documentation for the code" OFF)

project(cuevm
VERSION 0.1.0
DESCRIPTION "A CUDA EVM implementation"
LANGUAGES CUDA CXX)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

include_directories("${PROJECT_SOURCE_DIR}/CGBN/include")

if(WITH_DOCS)
add_subdirectory("${PROJECT_SOURCE_DIR}/docs")
endif()
if(WITH_COMPILE)
add_subdirectory("${PROJECT_SOURCE_DIR}/src")
endif()
42 changes: 32 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
# Object files
objects = cuevm.o cuevm_test.o stack.o uint256.o

# Compiler
NVCC = nvcc
NVCC_FLAGS = -I./CGBN/include -lstdc++ -lm -lgmp -lcjson -rdc=true --std c++20 -lcudadevrt -lineinfo
GCC = gcc
GCC_FLAGS = -lm -lgmp -lcjson
GPP = g++
GPP_FLAGS = -I./CGBN/include -lm -lgmp -lcjson
OUT_DIRECTORY = ./out


test_gmp: src/test/test_gmp.c
$(GCC) -o $(OUT_DIRECTORY)/test_gmp src/test/test_gmp.c $(GCC_FLAGS)

test_cjson: src/test/test_cjson.c
$(GCC) -o $(OUT_DIRECTORY)/test_cjson src/test/test_cjson.c $(GCC_FLAGS)

test_cjson_evm: src/test/test_cjson_evm.c
$(GCC) -o $(OUT_DIRECTORY)/test_cjson_evm src/test/test_cjson_evm.c $(GCC_FLAGS)

test_cgbn: src/test/test_cgbn.cu
$(NVCC) $(NVCC_FLAGS) -o $(OUT_DIRECTORY)/test_cgbn src/test/test_cgbn.cu

interpreter: src/interpreter.cu
$(NVCC) -D TRACER $(NVCC_FLAGS) -o $(OUT_DIRECTORY)/$@ $<

debug_interpreter: src/interpreter.cu
$(NVCC) -D TRACER $(NVCC_FLAGS) -g -G -o $(OUT_DIRECTORY)/$@ $<

# Compiler Flags
NVCC_FLAGS = -I./include -lstdc++ -dc
cpu_interpreter: src/interpreter.cu
$(NVCC) -D TRACER -D ONLY_CPU -D GAS $(NVCC_FLAGS) -g -G -o $(OUT_DIRECTORY)/$@ $<

all: $(objects)
$(NVCC) $(objects) -o cuEVM
cpu_debug_interpreter: src/interpreter.cu
$(NVCC) -D TRACER -D COMPLEX_TRACER -D ONLY_CPU -D GAS $(NVCC_FLAGS) -g -G -o $(OUT_DIRECTORY)/$@ $<

%.o: src/%.cu
$(NVCC) $(NVCC_FLAGS) $< -o $@
% :: src/test/%.cu
$(NVCC) $(NVCC_FLAGS) -g -G -o $(OUT_DIRECTORY)/$@ $<

clean:
rm -f *.o cuEVM
rm -f $(OUT_DIRECTORY)/*
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ Cuda implementation of EVM bytecode executor
- A C++ compiler compatible with the CUDA Toolkit

## Compile
* `make`
Or with custom nvcc path
* `make NVCC=/usr/local/cuda-10.0/bin/nvcc`
* `make interpreter`
Or for running with cpu
* `make cpu_interpreter`

## Usage

* `./cuEVM --bytecode [hex string of byte code] --input [hex string of input]`
* `clear && compute-sanitizer --tool memcheck --leak-check=full ./out/interpreter --input [inpot_json_file] --output [output_json_file]`
* `clear && valgrind --leak-check=full --show-leak-kinds=all ./out/*`
Or for running with cpu
* `./out/cpu_interpreter --input [inpot_json_file] --output [output_json_file]`
Easy test:
* `./out/cpu_interpreter --input ./input/evm_arith.json --output ./output/evm_test.json`

Sample testing bytecode :

Expand Down Expand Up @@ -75,3 +80,7 @@ TODO: change options, configs, and how we use the tool in the future.

## Code structure
TODO

## Documentation
TODO
docygen+sphinx+breathe+exhale
1 change: 1 addition & 0 deletions REVMI
Submodule REVMI added at 7deee0
24 changes: 24 additions & 0 deletions cmake/FindGMP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set(GMP_PREFIX "" CACHE PATH "path ")


find_path(GMP_INCLUDE_DIR gmp.h gmpxx.h
PATHS ${GMP_PREFIX}/include /usr/include /usr/local/include )

find_library(GMP_LIBRARY NAMES gmp libgmp
PATHS ${GMP_PREFIX}/lib /usr/lib /usr/local/lib)


if(GMP_INCLUDE_DIR AND GMP_LIBRARY)
get_filename_component(GMP_LIBRARY_DIR ${GMP_LIBRARY} PATH)
set(GMP_FOUND TRUE)
endif()

if(GMP_FOUND)
if(NOT GMP_FIND_QUIETLY)
MESSAGE(STATUS "Found GMP: ${GMP_LIBRARY}")
endif()
elseif(GMP_FOUND)
if(GMP_FIND_REQUIRED)
message(FATAL_ERROR "Could not find GMP")
endif()
endif()
11 changes: 11 additions & 0 deletions cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Look for an executable called sphinx-build
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
DOC "Path to sphinx-build executable")

include(FindPackageHandleStandardArgs)

#Handle standard arguments to find_package like REQUIRED and QUIET
find_package_handle_standard_args(Sphinx
"Failed to find sphinx-build executable"
SPHINX_EXECUTABLE)
Loading