diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..6b5e018 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,99 @@ +[submodule "vendor/nimbus-build-system"] + path = vendor/nimbus-build-system + url = https://github.com/status-im/nimbus-build-system.git +[submodule "vendor/nim-libp2p"] + path = vendor/nim-libp2p + url = https://github.com/vacp2p/nim-libp2p.git +[submodule "vendor/nimcrypto"] + path = vendor/nimcrypto + url = https://github.com/cheatfate/nimcrypto.git +[submodule "vendor/nim-chronicles"] + path = vendor/nim-chronicles + url = https://github.com/status-im/nim-chronicles.git +[submodule "vendor/nim-metrics"] + path = vendor/nim-metrics + url = https://github.com/status-im/nim-metrics.git +[submodule "vendor/nim-secp256k1"] + path = vendor/nim-secp256k1 + url = https://github.com/status-im/nim-secp256k1.git +[submodule "nim-stew"] + path = nim-stew + url = https://github.com/status-im/nim-stew.git +[submodule "vendor/questionable"] + path = vendor/questionable + url = https://github.com/status-im/questionable.git +[submodule "vendor/upraises"] + path = vendor/upraises + url = https://github.com/markspanbroek/upraises.git +[submodule "vendor/asynctest"] + path = vendor/asynctest + url = https://github.com/status-im/asynctest.git +[submodule "vendor/nim-confutils"] + path = vendor/nim-confutils + url = https://github.com/status-im/nim-confutils.git +[submodule "vendor/nim-nat-traversal"] + path = vendor/nim-nat-traversal + url = https://github.com/status-im/nim-nat-traversal.git +[submodule "vendor/nim-libbacktrace"] + path = vendor/nim-libbacktrace + url = https://github.com/status-im/nim-libbacktrace.git +[submodule "vendor/nim-chronos"] + path = vendor/nim-chronos + url = https://github.com/status-im/nim-chronos.git +[submodule "vendor/nim-json-serialization"] + path = vendor/nim-json-serialization + url = https://github.com/status-im/nim-json-serialization.git +[submodule "vendor/nim-serialization"] + path = vendor/nim-serialization + url = https://github.com/status-im/nim-serialization.git +[submodule "vendor/nim-bearssl"] + path = vendor/nim-bearssl + url = https://github.com/status-im/nim-bearssl.git +[submodule "vendor/stint"] + path = vendor/stint + url = https://github.com/status-im/stint.git +[submodule "vendor/nim-unittest2"] + path = vendor/nim-unittest2 + url = https://github.com/status-im/nim-unittest2.git +[submodule "vendor/nim-websock"] + path = vendor/nim-websock + url = https://github.com/status-im/nim-websock.git +[submodule "vendor/nim-contract-abi"] + path = vendor/nim-contract-abi + url = https://github.com/status-im/nim-contract-abi +[submodule "vendor/nim-json-rpc"] + path = vendor/nim-json-rpc + url = https://github.com/status-im/nim-json-rpc +[submodule "vendor/nim-ethers"] + path = vendor/nim-ethers + url = https://github.com/status-im/nim-ethers +[submodule "vendor/lrucache.nim"] + path = vendor/lrucache.nim + url = https://github.com/status-im/lrucache.nim +[submodule "vendor/nim-blscurve"] + path = vendor/nim-blscurve + url = https://github.com/status-im/nim-blscurve.git +[submodule "vendor/nim-codex-dht"] + path = vendor/nim-codex-dht + url = https://github.com/codex-storage/nim-codex-dht.git +[submodule "vendor/nim-eth"] + path = vendor/nim-eth + url = https://github.com/status-im/nim-eth +[submodule "vendor/codex-contracts-eth"] + path = vendor/codex-contracts-eth + url = https://github.com/status-im/codex-contracts-eth +[submodule "vendor/nim-protobuf-serialization"] + path = vendor/nim-protobuf-serialization + url = https://github.com/status-im/nim-protobuf-serialization +[submodule "vendor/nim-results"] + path = vendor/nim-results + url = https://github.com/arnetheduck/nim-results +[submodule "vendor/nim-testutils"] + path = vendor/nim-testutils + url = https://github.com/status-im/nim-testutils +[submodule "vendor/nim-serde"] + path = vendor/nim-serde + url = https://github.com/codex-storage/nim-serde.git +[submodule "vendor/nph"] + path = vendor/nph + url = https://github.com/arnetheduck/nph.git diff --git a/build.nims b/build.nims new file mode 100644 index 0000000..8866032 --- /dev/null +++ b/build.nims @@ -0,0 +1,123 @@ +mode = ScriptMode.Verbose + +import std/os except commandLineParams + +### Helper functions +proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = + if not dirExists "build": + mkDir "build" + + # allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims" + var extra_params = params + when compiles(commandLineParams): + for param in commandLineParams(): + extra_params &= " " & param + else: + for i in 2 ..< paramCount(): + extra_params &= " " & paramStr(i) + + let + # Place build output in 'build' folder, even if name includes a longer path. + outName = os.lastPathPart(name) + cmd = + "nim " & lang & " --out:build/" & outName & " " & extra_params & " " & srcDir & + name & ".nim" + + exec(cmd) + +proc test(name: string, srcDir = "tests/", params = "", lang = "c") = + buildBinary name, srcDir, params + exec "build/" & name + +task codex, "build codex binary": + buildBinary "codex", + params = "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE" + +task toolsCirdl, "build tools/cirdl binary": + buildBinary "tools/cirdl/cirdl" + +task testCodex, "Build & run Codex tests": + test "testCodex", params = "-d:codex_enable_proof_failures=true" + +task testContracts, "Build & run Codex Contract tests": + test "testContracts" + +task testIntegration, "Run integration tests": + buildBinary "codex", + params = + "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE -d:codex_enable_proof_failures=true" + test "testIntegration" + # use params to enable logging from the integration test executable + # test "testIntegration", params = "-d:chronicles_sinks=textlines[notimestamps,stdout],textlines[dynamic] " & + # "-d:chronicles_enabled_topics:integration:TRACE" + +task build, "build codex binary": + codexTask() + +task test, "Run tests": + testCodexTask() + +task testTools, "Run Tools tests": + toolsCirdlTask() + test "testTools" + +task testAll, "Run all tests (except for Taiko L2 tests)": + testCodexTask() + testContractsTask() + testIntegrationTask() + testToolsTask() + +task testTaiko, "Run Taiko L2 tests": + codexTask() + test "testTaiko" + +import strutils +import os + +task coverage, "generates code coverage report": + var (output, exitCode) = gorgeEx("which lcov") + if exitCode != 0: + echo " ************************** ⛔️ ERROR ⛔️ **************************" + echo " ** ERROR: lcov not found, it must be installed to run code **" + echo " ** coverage locally **" + echo " *****************************************************************" + quit 1 + + (output, exitCode) = gorgeEx("gcov --version") + if output.contains("Apple LLVM"): + echo " ************************* ⚠️ WARNING ⚠️ *************************" + echo " ** WARNING: Using Apple's llvm-cov in place of gcov, which **" + echo " ** emulates an old version of gcov (4.2.0) and therefore **" + echo " ** coverage results will differ than those on CI (which **" + echo " ** uses a much newer version of gcov). **" + echo " *****************************************************************" + + var nimSrcs = " " + for f in walkDirRec("codex", {pcFile}): + if f.endswith(".nim"): + nimSrcs.add " " & f.absolutePath.quoteShell() + + echo "======== Running Tests ======== " + test "coverage", + srcDir = "tests/", + params = + " --nimcache:nimcache/coverage -d:release -d:codex_enable_proof_failures=true" + exec("rm nimcache/coverage/*.c") + rmDir("coverage") + mkDir("coverage") + echo " ======== Running LCOV ======== " + exec( + "lcov --capture --keep-going --directory nimcache/coverage --output-file coverage/coverage.info" + ) + exec( + "lcov --extract coverage/coverage.info --keep-going --output-file coverage/coverage.f.info " & + nimSrcs + ) + echo " ======== Generating HTML coverage report ======== " + exec("genhtml coverage/coverage.f.info --keep-going --output-directory coverage/report ") + echo " ======== Coverage report Done ======== " + +task showCoverage, "open coverage html": + echo " ======== Opening HTML coverage report in browser... ======== " + if findExe("open") != "": + exec("open coverage/report/index.html") diff --git a/env.sh b/env.sh new file mode 100644 index 0000000..697a426 --- /dev/null +++ b/env.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# We use ${BASH_SOURCE[0]} instead of $0 to allow sourcing this file +# and we fall back to a Zsh-specific special var to also support Zsh. +REL_PATH="$(dirname ${BASH_SOURCE[0]:-${(%):-%x}})" +ABS_PATH="$(cd ${REL_PATH}; pwd)" +source ${ABS_PATH}/vendor/nimbus-build-system/scripts/env.sh diff --git a/nim-stew b/nim-stew new file mode 160000 index 0000000..58abb48 --- /dev/null +++ b/nim-stew @@ -0,0 +1 @@ +Subproject commit 58abb4891f97c6cdc07335e868414e0c7b736c68 diff --git a/vendor/asynctest b/vendor/asynctest new file mode 160000 index 0000000..572c897 --- /dev/null +++ b/vendor/asynctest @@ -0,0 +1 @@ +Subproject commit 572c897a4e1177e905105a3bafe8c5573d9bae83 diff --git a/vendor/codex-contracts-eth b/vendor/codex-contracts-eth new file mode 160000 index 0000000..0bf1385 --- /dev/null +++ b/vendor/codex-contracts-eth @@ -0,0 +1 @@ +Subproject commit 0bf138512b7c1c3b8d77c48376e47f702e47106c diff --git a/vendor/lrucache.nim b/vendor/lrucache.nim new file mode 160000 index 0000000..8767ade --- /dev/null +++ b/vendor/lrucache.nim @@ -0,0 +1 @@ +Subproject commit 8767ade0b76ea5b5d4ce24a52d0c58a6ebeb66cd diff --git a/vendor/nim-bearssl b/vendor/nim-bearssl new file mode 160000 index 0000000..667b404 --- /dev/null +++ b/vendor/nim-bearssl @@ -0,0 +1 @@ +Subproject commit 667b40440a53a58e9f922e29e20818720c62d9ac diff --git a/vendor/nim-blscurve b/vendor/nim-blscurve new file mode 160000 index 0000000..de2d3c7 --- /dev/null +++ b/vendor/nim-blscurve @@ -0,0 +1 @@ +Subproject commit de2d3c79264bba18dbea469c8c5c4b3bb3c8bc55 diff --git a/vendor/nim-chronicles b/vendor/nim-chronicles new file mode 160000 index 0000000..81a4a7a --- /dev/null +++ b/vendor/nim-chronicles @@ -0,0 +1 @@ +Subproject commit 81a4a7a360c78be9c80c8f735c76b6d4a1517304 diff --git a/vendor/nim-chronos b/vendor/nim-chronos new file mode 160000 index 0000000..c04576d --- /dev/null +++ b/vendor/nim-chronos @@ -0,0 +1 @@ +Subproject commit c04576d829b8a0a1b12baaa8bc92037501b3a4a0 diff --git a/vendor/nim-codex-dht b/vendor/nim-codex-dht new file mode 160000 index 0000000..f6eef1a --- /dev/null +++ b/vendor/nim-codex-dht @@ -0,0 +1 @@ +Subproject commit f6eef1ac95c70053b2518f1e3909c909ed8701a6 diff --git a/vendor/nim-confutils b/vendor/nim-confutils new file mode 160000 index 0000000..cb858a2 --- /dev/null +++ b/vendor/nim-confutils @@ -0,0 +1 @@ +Subproject commit cb858a27f4347be949d10ed74b58713d687936d2 diff --git a/vendor/nim-contract-abi b/vendor/nim-contract-abi new file mode 160000 index 0000000..842f489 --- /dev/null +++ b/vendor/nim-contract-abi @@ -0,0 +1 @@ +Subproject commit 842f48910be4f388bcbf8abf1f02aba1d5e2ee64 diff --git a/vendor/nim-eth b/vendor/nim-eth new file mode 160000 index 0000000..dcfbc42 --- /dev/null +++ b/vendor/nim-eth @@ -0,0 +1 @@ +Subproject commit dcfbc4291d39b59563828c3e32be4d51a2f25931 diff --git a/vendor/nim-ethers b/vendor/nim-ethers new file mode 160000 index 0000000..bbced46 --- /dev/null +++ b/vendor/nim-ethers @@ -0,0 +1 @@ +Subproject commit bbced4673316763c6ef931b4d0a08069cde2474c diff --git a/vendor/nim-json-rpc b/vendor/nim-json-rpc new file mode 160000 index 0000000..2743721 --- /dev/null +++ b/vendor/nim-json-rpc @@ -0,0 +1 @@ +Subproject commit 274372132de497e6b7b793c9d5d5474b71bf80a2 diff --git a/vendor/nim-json-serialization b/vendor/nim-json-serialization new file mode 160000 index 0000000..6eadb6e --- /dev/null +++ b/vendor/nim-json-serialization @@ -0,0 +1 @@ +Subproject commit 6eadb6e939ffa7882ff5437033c11a9464d3385c diff --git a/vendor/nim-libbacktrace b/vendor/nim-libbacktrace new file mode 160000 index 0000000..6da0cda --- /dev/null +++ b/vendor/nim-libbacktrace @@ -0,0 +1 @@ +Subproject commit 6da0cda88ab7780bd5fd342327adb91ab84692aa diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p new file mode 160000 index 0000000..c08d807 --- /dev/null +++ b/vendor/nim-libp2p @@ -0,0 +1 @@ +Subproject commit c08d80734989b028b3d1705f2188d783a343aac0 diff --git a/vendor/nim-metrics b/vendor/nim-metrics new file mode 160000 index 0000000..cacfdc1 --- /dev/null +++ b/vendor/nim-metrics @@ -0,0 +1 @@ +Subproject commit cacfdc12454a0804c65112b9f4f50d1375208dcd diff --git a/vendor/nim-nat-traversal b/vendor/nim-nat-traversal new file mode 160000 index 0000000..6508ce7 --- /dev/null +++ b/vendor/nim-nat-traversal @@ -0,0 +1 @@ +Subproject commit 6508ce75060878dfcdfa21f94721672c69a1823b diff --git a/vendor/nim-protobuf-serialization b/vendor/nim-protobuf-serialization new file mode 160000 index 0000000..5a31137 --- /dev/null +++ b/vendor/nim-protobuf-serialization @@ -0,0 +1 @@ +Subproject commit 5a31137a82c2b6a989c9ed979bb636c7a49f570e diff --git a/vendor/nim-results b/vendor/nim-results new file mode 160000 index 0000000..df8113d --- /dev/null +++ b/vendor/nim-results @@ -0,0 +1 @@ +Subproject commit df8113dda4c2d74d460a8fa98252b0b771bf1f27 diff --git a/vendor/nim-secp256k1 b/vendor/nim-secp256k1 new file mode 160000 index 0000000..2acbbdc --- /dev/null +++ b/vendor/nim-secp256k1 @@ -0,0 +1 @@ +Subproject commit 2acbbdcc0e63002a013fff49f015708522875832 diff --git a/vendor/nim-serde b/vendor/nim-serde new file mode 160000 index 0000000..5ced7c8 --- /dev/null +++ b/vendor/nim-serde @@ -0,0 +1 @@ +Subproject commit 5ced7c88b97d99c582285ce796957fb71fd42434 diff --git a/vendor/nim-serialization b/vendor/nim-serialization new file mode 160000 index 0000000..2086c99 --- /dev/null +++ b/vendor/nim-serialization @@ -0,0 +1 @@ +Subproject commit 2086c99608b4bf472e1ef5fe063710f280243396 diff --git a/vendor/nim-testutils b/vendor/nim-testutils new file mode 160000 index 0000000..4d37244 --- /dev/null +++ b/vendor/nim-testutils @@ -0,0 +1 @@ +Subproject commit 4d37244f9f5e1acd8592a4ceb5c3fc47bc160181 diff --git a/vendor/nim-unittest2 b/vendor/nim-unittest2 new file mode 160000 index 0000000..845b6af --- /dev/null +++ b/vendor/nim-unittest2 @@ -0,0 +1 @@ +Subproject commit 845b6af28b9f68f02d320e03ad18eccccea7ddb9 diff --git a/vendor/nim-websock b/vendor/nim-websock new file mode 160000 index 0000000..ebe308a --- /dev/null +++ b/vendor/nim-websock @@ -0,0 +1 @@ +Subproject commit ebe308a79a7b440a11dfbe74f352be86a3883508 diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system new file mode 160000 index 0000000..0be0663 --- /dev/null +++ b/vendor/nimbus-build-system @@ -0,0 +1 @@ +Subproject commit 0be0663e1af76e869837226a4ef3e586fcc737d3 diff --git a/vendor/nimcrypto b/vendor/nimcrypto new file mode 160000 index 0000000..dc07e30 --- /dev/null +++ b/vendor/nimcrypto @@ -0,0 +1 @@ +Subproject commit dc07e3058c6904eef965394493b6ea99aa2adefc diff --git a/vendor/nph b/vendor/nph new file mode 160000 index 0000000..f1f0477 --- /dev/null +++ b/vendor/nph @@ -0,0 +1 @@ +Subproject commit f1f047760c6cb38d5c55d0ddb29b57a9c008a976 diff --git a/vendor/questionable b/vendor/questionable new file mode 160000 index 0000000..47692e0 --- /dev/null +++ b/vendor/questionable @@ -0,0 +1 @@ +Subproject commit 47692e0d923ada8f7f731275b2a87614c0150987 diff --git a/vendor/stint b/vendor/stint new file mode 160000 index 0000000..5c5e01c --- /dev/null +++ b/vendor/stint @@ -0,0 +1 @@ +Subproject commit 5c5e01cef089a261474b7abfe246b37447aaa8ed diff --git a/vendor/upraises b/vendor/upraises new file mode 160000 index 0000000..bc26289 --- /dev/null +++ b/vendor/upraises @@ -0,0 +1 @@ +Subproject commit bc2628989b63854d980e92dadbd58f83e34b6f25