Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
make unicorn a git module
Browse files Browse the repository at this point in the history
  • Loading branch information
norswap committed May 9, 2022
1 parent a202045 commit 95d3ee1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
node_modules
artifacts
cache
unicorn
unicorn2
.*.swp
venv
.idea
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
branch = l2minigeth
path = minigeth
url = git@github.com:ethereum-optimism/minigeth.git
[submodule "unicorn"]
path = unicorn
url = git@github.com:unicorn-engine/unicorn.git
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
SHELL := /bin/bash

build: unicorn submodule minigeth_mips minigeth_default_arch mipsevm contracts
build: submodules unicorn minigeth_mips minigeth_default_arch mipsevm contracts

unicorn:
./build_unicorn.sh

submodule:
submodules:
# CI will checkout submodules on its own (and fails on these commands)
if [[ -z "$$GITHUB_ENV" ]]; then \
git submodule init; \
Expand All @@ -31,11 +31,16 @@ nodejs:
npm install; \
fi

# Must be a definition and not a rule, otherwise it gets only called once and
# not before each test as we wish.
define clear_cache
rm -rf /tmp/cannon
mkdir -p /tmp/cannon
endef

clear_cache:
$(call clear_cache)

test_challenge:
$(call clear_cache)
# Build preimage cache for block 13284469
Expand Down Expand Up @@ -82,5 +87,5 @@ mrproper: clean
rm -rf node_modules
rm -rf mipigo/venv

.PHONY: build unicorn submodule minigeth_mips minigeth_default_arch mipsevm contracts \
nodejs clean mrproper test_challenge test_mipsevm test_minigeth test
.PHONY: build unicorn submodules minigeth_mips minigeth_default_arch mipsevm contracts \
nodejs clean mrproper test_challenge test_mipsevm test_minigeth test clear_cache
19 changes: 9 additions & 10 deletions build_unicorn.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env bash
if [[ ! -d unicorn2 ]]; then
git clone https://github.com/geohot/unicorn.git -b dev unicorn2
#git clone https://github.com/unicorn-engine/unicorn.git -b dev unicorn2
fi

cd unicorn2
cmake . -DUNICORN_ARCH=mips -DCMAKE_BUILD_TYPE=Release
#cmake . -DUNICORN_ARCH=mips -DCMAKE_BUILD_TYPE=Debug
cd unicorn
mkdir -p build
cd build
cmake .. -DUNICORN_ARCH=mips -DCMAKE_BUILD_TYPE=Release
make -j8

# The Go linker / runtime expects these to be there!
cp libunicorn.so.1 ..
cp libunicorn.so.2 ..

# export LIBUNICORN_PATH for Github CI
# TODO: is this actually needed?
if [[ ! -z "$GITHUB_ENV" ]]; then
echo "LIBUNICORN_PATH=$(pwd)/unicorn2/" >> $GITHUB_ENV
echo "LIBUNICORN_PATH=$(pwd)/unicorn/" >> $GITHUB_ENV
fi
2 changes: 1 addition & 1 deletion mipsevm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

replace github.com/ethereum/go-ethereum => ../minigeth

replace github.com/unicorn-engine/unicorn => ../unicorn2
replace github.com/unicorn-engine/unicorn => ../unicorn

require (
github.com/ethereum/go-ethereum v1.10.8
Expand Down
1 change: 1 addition & 0 deletions unicorn
Submodule unicorn added at e5e130

0 comments on commit 95d3ee1

Please sign in to comment.