-
Notifications
You must be signed in to change notification settings - Fork 120
/
nimbus.nimble
131 lines (106 loc) · 5.23 KB
/
nimbus.nimble
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
# nimbus
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
mode = ScriptMode.Verbose
packageName = "nimbus"
version = "0.1.0"
author = "Status Research & Development GmbH"
description = "An Ethereum 2.0 Sharding Client for Resource-Restricted Devices"
license = "Apache License 2.0"
skipDirs = @["tests", "examples"]
# we can't have the result of a custom task in the "bin" var - https://github.com/nim-lang/nimble/issues/542
# bin = @["build/nimbus"]
requires "nim >= 1.6.0",
"bncurve",
"chronicles",
"chronos",
"eth",
"json_rpc",
"libbacktrace",
"nimcrypto",
"stew",
"stint",
"rocksdb",
"ethash",
"blscurve",
"evmc",
"web3",
"minilru"
binDir = "build"
when declared(namedBin):
namedBin = {
"nimbus/nimbus_execution_client": "nimbus_execution_client",
"fluffy/fluffy": "fluffy",
"nimbus_verified_proxy/nimbus_verified_proxy": "nimbus_verified_proxy",
}.toTable()
import std/os
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
for i in 2..<paramCount():
extra_params &= " " & paramStr(i)
exec "nim " & lang & " --out:build/" & name & " " & extra_params & " " & srcDir & name & ".nim"
proc test(path: string, name: string, params = "", lang = "c") =
# Verify stack usage is kept low by setting 1mb stack limit in tests.
const stackLimitKiB = 1024
when not defined(windows):
const (buildOption, runPrefix) = ("", "ulimit -s " & $stackLimitKiB & " && ")
else:
# No `ulimit` in Windows. `ulimit -s` in Bash is accepted but has no effect.
# See https://public-inbox.org/git/alpine.DEB.2.21.1.1709131448390.4132@virtualbox/
# Also, the command passed to NimScript `exec` on Windows is not a shell script.
# Instead, we can set stack size at link time.
const (buildOption, runPrefix) =
(" -d:windowsNoSetStack --passL:-Wl,--stack," & $(stackLimitKiB * 2048), "")
buildBinary name, (path & "/"), params & buildOption
exec runPrefix & "build/" & name
task test, "Run tests":
test "tests", "all_tests", "-d:chronicles_log_level=ERROR -d:unittest2DisableParamFiltering"
task test_rocksdb, "Run rocksdb tests":
test "tests/db", "test_kvstore_rocksdb", "-d:chronicles_log_level=ERROR -d:unittest2DisableParamFiltering"
task test_import, "Run block import test":
let tmp = getTempDir() / "nimbus-eth1-block-import"
if dirExists(tmp):
echo "Remove directory before running test: " & tmp
quit(QuitFailure)
const nimbus_exec_client = when defined(windows):
"build/nimbus_execution_client.exe"
else:
"build/nimbus_execution_client"
if not fileExists(nimbus_exec_client):
echo "Build nimbus execution client before running this test"
quit(QuitFailure)
# Test that we can resume import
exec "build/nimbus_execution_client import --data-dir:" & tmp & " --era1-dir:tests/replay --max-blocks:1"
exec "build/nimbus_execution_client import --data-dir:" & tmp & " --era1-dir:tests/replay --max-blocks:1023"
# There should only be 8k blocks
exec "build/nimbus_execution_client import --data-dir:" & tmp & " --era1-dir:tests/replay --max-blocks:10000"
task test_evm, "Run EVM tests":
test "tests", "evm_tests", "-d:chronicles_log_level=ERROR -d:unittest2DisableParamFiltering"
## Fluffy tasks
task fluffy, "Build fluffy":
buildBinary "fluffy", "fluffy/", "-d:chronicles_log_level=TRACE"
task fluffy_test, "Run fluffy tests":
# Need the nimbus_db_backend in state network tests as we need a Hexary to
# start from, even though it only uses the MemoryDb.
test "fluffy/tests/portal_spec_tests/mainnet", "all_fluffy_portal_spec_tests", "-d:chronicles_log_level=ERROR -d:nimbus_db_backend=sqlite"
# Seperate build for these tests as they are run with a low `mergeBlockNumber`
# to make the tests faster. Using the real mainnet merge block number is not
# realistic for these tests.
test "fluffy/tests", "all_fluffy_tests", "-d:chronicles_log_level=ERROR -d:nimbus_db_backend=sqlite -d:mergeBlockNumber:38130"
task utp_test_app, "Build uTP test app":
buildBinary "utp_test_app", "fluffy/tools/utp_testing/", "-d:chronicles_log_level=TRACE"
task utp_test, "Run uTP integration tests":
test "fluffy/tools/utp_testing", "utp_test", "-d:chronicles_log_level=ERROR"
task test_portal_testnet, "Build test_portal_testnet":
buildBinary "test_portal_testnet", "fluffy/scripts/", "-d:chronicles_log_level=DEBUG -d:unittest2DisableParamFiltering"
## Nimbus Verified Proxy tasks
task nimbus_verified_proxy, "Build Nimbus verified proxy":
buildBinary "nimbus_verified_proxy", "nimbus_verified_proxy/", "-d:chronicles_log_level=TRACE"
task nimbus_verified_proxy_test, "Run Nimbus verified proxy tests":
test "nimbus_verified_proxy/tests", "test_proof_validation", "-d:chronicles_log_level=ERROR -d:nimbus_db_backend=sqlite"