forked from runtimeverification/iele-semantics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
237 lines (186 loc) · 12.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# Common to all versions of K
# ===========================
ifeq ($(BYTE),yes)
EXT=cmo
LIBEXT=cma
DLLEXT=cma
OCAMLC=c
LIBFLAG=-a
else
EXT=cmx
LIBEXT=cmxa
DLLEXT=cmxs
OCAMLC=opt -O3 -cclib -Wl,-rpath=/usr/local/lib
LIBFLAG=-shared
endif
ifeq ($(COVERAGE),k)
KOMPILE_FLAGS=--coverage
else ifeq ($(COVERAGE),ocaml)
BISECT=-package bisect_ppx
PREDICATES=-predicates coverage
endif
export PATH:=$(shell cd compiler && stack path --local-install-root)/bin:${PATH}
.PHONY: all clean distclean build tangle defn proofs split-tests test vm-test blockchain-test deps k-deps ocaml-deps assembler iele-test iele-test-node node testnode install kore
.SECONDARY:
all: build split-vm-tests testnode
clean:
rm -rf .build/standalone .build/kore .build/node .build/check .build/plugin-node .build/plugin-standalone .build/vm compiler/.stack-work
distclean: clean
cd tests/ci/rv-k && mvn clean
build: tangle .build/standalone/iele-testing-kompiled/interpreter .build/vm/iele-vm assembler .build/check/well-formedness-kompiled/interpreter
kore: tangle .build/kore/iele-testing.kore
assembler:
cd compiler && stack build --install-ghc
install: assembler
cd compiler && stack install
cp .build/vm/iele-vm .build/vm/iele-test-client .build/vm/iele-test-vm ~/.local/bin
# Tangle from *.md files
# ----------------------
tangle: defn proofs
k_files:=iele-testing.k data.k iele.k iele-gas.k iele-binary.k krypto.k iele-syntax.k iele-node.k well-formedness.k
standalone_files:=$(patsubst %,.build/standalone/%,$(k_files))
node_files:=$(patsubst %,.build/node/%,$(k_files))
checker_files:=.build/standalone/iele-syntax.k .build/standalone/well-formedness.k .build/standalone/data.k
defn_files=$(standalone_files) $(node_files)
source_files=$(patsubst %.k,%.md,$(k_files))
defn: $(defn_files)
export LUA_PATH=$(shell pwd)/.build/tangle/?.lua;;
.build/node/%.k: %.md
@echo "== tangle: $@"
mkdir -p $(dir $@)
pandoc --from markdown --to .build/tangle/tangle.lua --metadata=code:".k:not(.standalone),.node" $< > $@
.build/standalone/%.k: %.md
@echo "== tangle: $@"
mkdir -p $(dir $@)
pandoc --from markdown --to .build/tangle/tangle.lua --metadata=code:".k:not(.node),.standalone" $< > $@
node: .build/vm/iele-vm
testnode : .build/vm/iele-test-vm .build/vm/iele-test-client
proof_dir=tests/proofs
proof_files=
proofs: $(proof_files)
# Tests
# -----
split-tests: split-vm-tests split-blockchain-tests
invalid_iele_tests_file=tests/failing.expected
invalid_iele_tests= $(shell cat ${invalid_iele_tests_file})
split-vm-tests: \
$(patsubst tests/ethereum-tests/%.json,tests/%/make.timestamp, $(filter-out ${invalid_iele_tests}, $(wildcard tests/ethereum-tests/VMTests/*/*.json))) \
split-blockchain-tests: \
$(patsubst tests/ethereum-tests/%.json,tests/%/make.timestamp, $(filter-out ${invalid_iele_tests}, $(wildcard tests/ethereum-tests/BlockchainTests/GeneralStateTests/*/*.json))) \
vm_tests=$(wildcard tests/VMTests/*/*/*.iele.json)
blockchain_tests=$(wildcard tests/BlockchainTests/*/*/*/*.iele.json)
all_tests=${vm_tests} ${blockchain_tests}
skipped_tests=$(wildcard tests/VMTests/vmPerformance/*/*.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/*/*/*_Frontier.iele.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/*/*/*_Homestead.iele.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/*/*/*_EIP150.iele.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/*/*/*_EIP158.iele.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/*/*/*_Constantinople.iele.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/stQuadraticComplexityTest/*/*.iele.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/stStaticCall/static_Call50000*/*.iele.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/stStaticCall/static_Return50000*/*.iele.json) \
$(wildcard tests/BlockchainTests/GeneralStateTests/stStaticCall/static_Call1MB1024Calldepth_d1g0v0/*.iele.json) \
passing_tests=$(filter-out ${skipped_tests}, ${all_tests})
passing_vm_tests=$(filter-out ${skipped_tests}, ${vm_tests})
passing_blockchain_tests=$(filter-out ${skipped_tests}, ${blockchain_tests})
passing_targets=${passing_tests:=.test}
passing_vm_targets=${passing_vm_tests:=.test}
passing_blockchain_targets=${passing_blockchain_tests:=.test}
iele_tests=$(wildcard tests/iele/*/*/*.iele.json)
iele_targets=${iele_tests:=.test}
iele_node_targets=${iele_tests:=.nodetest}
iele_contracts=$(wildcard iele-examples/*.iele tests/iele/*/*/*.iele)
well_formed_contracts=$(filter-out $(wildcard tests/iele/*/ill-formed/*.iele), ${iele_contracts})
well_formedness_targets=${well_formed_contracts:=.test}
test: $(passing_targets) ${iele_targets} ${iele_node_targets} ${well_formedness_targets} test-bad-packet
vm-test: $(passing_vm_targets)
blockchain-test: $(passing_blockchain_targets)
iele-test: ${iele_targets}
iele-test-node: ${iele_node_targets}
well-formed-test: ${well_formedness_targets}
test-bad-packet:
netcat 127.0.0.1 $(PORT) -q 2 < tests/bad-packet
netcat 127.0.0.1 $(PORT) -q 2 < tests/bad-packet-2
.build/vm/iele-test-vm tests/iele/albe/sum/sum_zero.iele.json $(PORT)
tests/VMTests/%.json.test: tests/VMTests/%.json | .build/standalone/iele-testing-kompiled/interpreter
./vmtest $<
tests/BlockchainTests/%.json.test: tests/BlockchainTests/%.json | .build/standalone/iele-testing-kompiled/interpreter
./blockchaintest $<
tests/iele/%.json.test: tests/iele/%.json | .build/standalone/iele-testing-kompiled/interpreter
./blockchaintest $<
%.iele.test: %.iele | .build/check/well-formedness-kompiled/interpreter
./check-iele $<
PORT?=10000
tests/iele/%.nodetest: tests/iele/% | testnode
.build/vm/iele-test-vm $< $(PORT)
tests/%/make.timestamp: tests/ethereum-tests/%.json tests/evm-to-iele/evm-to-iele tests/evm-to-iele/evm-test-to-iele
@echo "== split: $@"
mkdir -p $(dir $@)
tests/split-test.py $< $(dir $@)
touch $@
tests/evm-to-iele/evm-to-iele: $(wildcard tests/evm-to-iele/*.ml tests/evm-to-iele/*.mli)
cd tests/evm-to-iele && ocamlfind $(OCAMLC) -g ieleUtil.mli ieleUtil.ml evm.mli evm.ml iele.mli iele.ml conversion.mli conversion.ml main.ml -package zarith -package hex -linkpkg -o evm-to-iele
tests/ethereum-tests/%.json:
@echo "== git submodule: cloning upstreams test repository"
git submodule update --init
K_BIN=tests/ci/rv-k/k-distribution/target/release/k/bin/
KOMPILE=${K_BIN}/kompile
coverage:
sed -i 's!.build/node/\(.*\)\.k:!\1.md:!' .build/node/iele-testing-kompiled/allRules.txt
sed -i 's!.build/standalone/\(.*\)\.k:!\1.md:!' .build/standalone/iele-testing-kompiled/allRules.txt .build/check/well-formedness-kompiled/allRules.txt
${K_BIN}/kcovr .build/node/iele-testing-kompiled .build/standalone/iele-testing-kompiled .build/check/well-formedness-kompiled -- $(filter-out krypto.md, $(source_files)) > .build/coverage.xml
deps: k-deps ocaml-deps
k-deps:
cd tests/ci/rv-k && mvn package
ocaml-deps:
opam init
opam repository add k "tests/ci/rv-k/k-distribution/target/release/k/lib/opam" || opam repository set-url k "tests/ci/rv-k/k-distribution/target/release/k/lib/opam"
opam update
opam switch 4.03.1+k
eval `opam config env` && opam install -y mlgmp zarith uuidm cryptokit secp256k1.0.3.2 bn128 hex ocaml-protoc rlp yojson ocp-ocamlres bisect_ppx
.build/kore/iele-testing.kore: $(defn_files)
@echo "== kompile: $@"
${KOMPILE} --debug --main-module IELE-TESTING --backend kore \
--syntax-module IELE-SYNTAX .build/standalone/iele-testing.k --directory .build/kore
.build/%/iele-testing-kompiled/constants.$(EXT): $(defn_files)
@echo "== kompile: $@"
${KOMPILE} --debug --main-module IELE-TESTING \
--syntax-module IELE-SYNTAX .build/$*/iele-testing.k --directory .build/$* \
--hook-namespaces "KRYPTO BLOCKCHAIN" --gen-ml-only -O3 --non-strict $(KOMPILE_FLAGS)
cd .build/$*/iele-testing-kompiled && ocamlfind $(OCAMLC) -c -g constants.ml -package gmp -package zarith -safe-string
.build/check/well-formedness-kompiled/interpreter: $(checker_files)
${KOMPILE} --debug --main-module IELE-WELL-FORMEDNESS-STANDALONE \
--syntax-module IELE-SYNTAX .build/standalone/well-formedness.k --directory .build/check \
--gen-ml-only -O3 --non-strict $(KOMPILE_FLAGS)
cd .build/check/well-formedness-kompiled && ocamlfind $(OCAMLC) -c -g -package gmp -package zarith -package uuidm -safe-string constants.ml prelude.ml plugin.ml parser.mli parser.ml lexer.ml run.ml
cd .build/check/well-formedness-kompiled && ocamlfind $(OCAMLC) -c -g -w -11-26 -package gmp -package zarith -package uuidm -safe-string realdef.ml -match-context-rows 2 -thread
cd .build/check/well-formedness-kompiled && ocamlfind $(OCAMLC) $(LIBFLAG) -o realdef.$(DLLEXT) realdef.$(EXT)
cd .build/check/well-formedness-kompiled && ocamlfind $(OCAMLC) -g -o interpreter constants.$(EXT) prelude.$(EXT) plugin.$(EXT) parser.$(EXT) lexer.$(EXT) run.$(EXT) interpreter.ml -package gmp -package dynlink -package zarith -package str -package uuidm -package unix -linkpkg -linkall -safe-string
.build/plugin-%/semantics.$(LIBEXT): $(wildcard plugin/plugin/*.ml plugin/plugin/*.mli) .build/%/iele-testing-kompiled/constants.$(EXT)
mkdir -p .build/plugin-$*
cp plugin/plugin/*.ml plugin/plugin/*.mli .build/plugin-$*
ocp-ocamlres -format ocaml plugin/plugin/proto/VERSION -o .build/plugin-$*/apiVersion.ml
ocaml-protoc plugin/plugin/proto/*.proto -ml_out .build/plugin-$*
cd .build/plugin-$* && ocamlfind $(OCAMLC) -c -g -I ../$*/iele-testing-kompiled msg_types.mli msg_types.ml msg_pb.mli msg_pb.ml apiVersion.ml world.mli world.ml caching.mli caching.ml BLOCKCHAIN.ml KRYPTO.ml -package cryptokit -package secp256k1 -package bn128 -package ocaml-protoc $(BISECT) -safe-string -thread
cd .build/plugin-$* && ocamlfind $(OCAMLC) -a -o semantics.$(LIBEXT) KRYPTO.$(EXT) msg_types.$(EXT) msg_pb.$(EXT) apiVersion.$(EXT) world.$(EXT) caching.$(EXT) BLOCKCHAIN.$(EXT) -thread
ocamlfind remove iele-semantics-plugin-$*
ocamlfind install iele-semantics-plugin-$* plugin/plugin/META .build/plugin-$*/semantics.* .build/plugin-$*/*.cmi .build/plugin-$*/*.$(EXT)
.build/%/iele-testing-kompiled/interpreter: .build/plugin-%/semantics.$(LIBEXT)
cd .build/$*/iele-testing-kompiled && ocamllex lexer.mll
cd .build/$*/iele-testing-kompiled && ocamlyacc parser.mly
cd .build/$*/iele-testing-kompiled && ocamlfind $(OCAMLC) -c -g -package gmp -package zarith -package uuidm -safe-string prelude.ml plugin.ml parser.mli parser.ml lexer.ml run.ml -thread
cd .build/$*/iele-testing-kompiled && ocamlfind $(OCAMLC) -c -g -w -11-26 -package gmp -package zarith -package uuidm -package iele-semantics-plugin-$* -safe-string realdef.ml -match-context-rows 2 -thread
cd .build/$*/iele-testing-kompiled && ocamlfind $(OCAMLC) $(LIBFLAG) -o realdef.$(DLLEXT) realdef.$(EXT)
cd .build/$*/iele-testing-kompiled && ocamlfind $(OCAMLC) -g -o interpreter constants.$(EXT) prelude.$(EXT) plugin.$(EXT) parser.$(EXT) lexer.$(EXT) run.$(EXT) interpreter.ml -package gmp -package dynlink -package zarith -package str -package uuidm -package unix -package iele-semantics-plugin-$* -linkpkg -linkall -thread -safe-string $(PREDICATES)
.build/vm/iele-test-vm: .build/node/iele-testing-kompiled/interpreter $(wildcard plugin/vm/*.ml plugin/vm/*.mli)
mkdir -p .build/vm
cp plugin/vm/*.ml plugin/vm/*.mli .build/vm
cd .build/vm && ocamlfind $(OCAMLC) -g -I ../node/iele-testing-kompiled -o iele-test-vm constants.$(EXT) prelude.$(EXT) plugin.$(EXT) parser.$(EXT) lexer.$(EXT) realdef.$(EXT) run.$(EXT) VM.mli VM.ml ieleClientUtils.ml ieleVmTest.ml -package gmp -package dynlink -package zarith -package str -package uuidm -package unix -package iele-semantics-plugin-node -package rlp -package yojson -package hex -linkpkg -linkall -thread -safe-string $(PREDICATES)
.build/vm/iele-vm: .build/node/iele-testing-kompiled/interpreter $(wildcard plugin/vm/*.ml plugin/vm/*.mli)
mkdir -p .build/vm
cp plugin/vm/*.ml plugin/vm/*.mli .build/vm
cd .build/vm && ocamlfind $(OCAMLC) -g -I ../node/iele-testing-kompiled -o iele-vm constants.$(EXT) prelude.$(EXT) plugin.$(EXT) parser.$(EXT) lexer.$(EXT) realdef.$(EXT) run.$(EXT) VM.mli VM.ml vmNetworkServer.ml -package gmp -package dynlink -package zarith -package str -package uuidm -package unix -package iele-semantics-plugin-node -package rlp -package yojson -package hex $(BISECT) -linkpkg -linkall -thread -safe-string $(PREDICATES)
.build/vm/iele-test-client: .build/node/iele-testing-kompiled/interpreter $(wildcard plugin/vm/*.ml plugin/vm/*.mli)
mkdir -p .build/vm
cp plugin/vm/*.ml plugin/vm/*.mli .build/vm
cd .build/vm && ocamlfind $(OCAMLC) -g -I ../node/iele-testing-kompiled -o iele-test-client constants.$(EXT) prelude.$(EXT) plugin.$(EXT) parser.$(EXT) lexer.$(EXT) realdef.$(EXT) run.$(EXT) VM.mli VM.ml ieleClientUtils.ml ieleApi.mli ieleApi.ml ieleApiClient.ml -package gmp -package dynlink -package zarith -package str -package uuidm -package unix -package iele-semantics-plugin-node -package rlp -package yojson -package hex -linkpkg -linkall -thread -safe-string $(PREDICATES)