Commit Graph

76 Commits

Author SHA1 Message Date
Kim De Mey 63b0945b52
Use json rpc client to run tests on portal testnet (#899)
Tests have also been added & adjusted. Original ones were actually
failing but unnoticed due to mistake in port passed in curl command.
2021-12-03 09:51:25 +01:00
Kim De Mey 02afda1b45
Run everything fluffy with chronosStrictException (#889) 2021-11-18 17:52:44 +01:00
jangko 7066b48303
add -d:unittest2DisableParamFiltering to .nimble
fix #840
2021-11-14 16:04:19 +07:00
Kim De Mey 8e26acc4eb
Move tools and add common types (#846)
* Move some duplicated types to common_types

* Move portalcli to tools/ and update the READMEs
2021-09-24 17:18:54 +02:00
Kim De Mey e37bafd47e
Add a first, simple, content network test (#760)
* Add a first, simple, content network test

* Use sqlite as nimbus_db_backend for fluffy tests

* Fix backend selection for sqlite
2021-07-15 15:12:33 +02:00
Kim De Mey 424fd405e9
Move Portal wire protocol from nim-eth to fluffy (#749)
* Move Portal wire protocol from nim-eth to fluffy

* Rename fluffy make targets

* Move all_fluffy_tests a folder down
2021-07-09 13:34:16 +02:00
KonradStaniec a59a2c61b6
[FEATURE] Add support for handling experimental api call (#746)
* [FEATURE] Add support for handling experimental api call
2021-07-07 11:04:18 +02:00
Kim De Mey f8b3922eb5
Change name from nlpn to fluffy (#734) 2021-06-28 17:53:13 +02:00
jangko 2269d16c4c
reintegrate test_rpc back into all_tests
for a long time, test_rpc will crash all_tests
if they are combined together. but now it works fine
2021-06-22 08:32:32 +07:00
Kim De Mey aef7a25174
Add nlpn (#714)
* Add start of nlpn client

* Fix some error handling in nlpn

* Clean-up GOARCH from nlpn.yml and add vendor to include paths
2021-06-16 21:18:45 +02:00
Jamie Lokier bfa7bd0488
Whisper: Stop testing Whisper
Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-06-01 18:12:47 +01:00
Jamie Lokier 8161de1a8f
Limit stack size on Windows like other targets
We can't use `ulimit -s` to limit stack size on Windows.  Even though Bash
accepts `ulimit -s` and the numbers change it has no effect and is not passed
to child processes.

(See https://public-inbox.org/git/alpine.DEB.2.21.1.1709131448390.4132@virtualbox/)

Instead, set it when building the test executable, following, a suggestion from
@stefantalpalaru.
https://github.com/status-im/nimbus-eth1/pull/598#discussion_r621107128

To ensure no conflict with `config.nims`, `-d:windowsNoSetStack` is used.  This
proved unnecessary in practice because the command-line option is passed to the
linker after the config file option.  But given we don't have an automated test
to verify linker behaviour, it's best not to rely on the option order, neither
how the linker treats it, or whether Nim will always send them in that order.

Testing:

This has been verified by using a smaller limit.  At 200k, all `ENABLE_EVMC=0`
OS targets passed as expected, and all `ENABLE_EVMC=1` OS targets failed with
expected kinds of errors due to stack overflow, including Windows.
(400k wasn't small enough; 32-bit x86 Windows passed on that).

Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-04-30 01:00:31 +01:00
Jamie Lokier a3c8a5c3f3
EVMC: Small stacks when using EVMC, closes #575 (segfaults)
This patch reduces stack space used with EVM in ENABLE_EVMC=1 mode, from 13 MB
worst case to 550 kB, a 24x reduction.

This completes fixing the "stack problem" and closes #575 (`EVM: Different
segmentation faults when running the test suite with EVMC`).

It also closes #256 (`recursive EVM call trigger unrecoverable stack overflow`).

After this patch, it is possible to re-enable the CI targets which had to be
disabled due to #575.

This change is also a required precursor for switching over to "nearly EVMC" as
the clean and focused Nimbus-internal API between EVM and sync/database
processes, and is also key to the use of Chronos `async` in those processes
when calling the EVM.

(The motivation is the internal interface has to be substantially changed
_anyway_ for the parallel sync and database processes, and EVMC turns out to be
well-designed and well-suited for this.  It provides good separation between
modules, and suits our needs better than our other current interface.  Might as
well use a good one designed by someone else.  EVMC is 98% done in Nimbus
thanks to great work done before by @jangko, and we can use Nimbus-specific
extensions where we need flexibility, including for performance.  Being aligned
with the ecosystem is a useful bonus feature.)

All tests below were run on Ubuntu 20.04 LTS server, x86-64.  This matches one
of the targets that has been disabled for a while in CI in EVMC mode due to
stack overflow crashing the tests, so it's a good choice.

Measurements before
===================

Testing commit `e76e0144 2021-04-22 11:29:42 +0700 add submodules: graphql and
toml-serialization`.

    $ rm -f build/all_tests && make ENABLE_EVMC=1 test
    $ ulimit -S -s 16384 # Requires larger stack than default to avoid crash.
    $ ./build/all_tests 9 | tee tlog
    [Suite] persist block json tests
    ...
    Stack range 38416 depthHigh 3
    ...
    Stack range 13074720 depthHigh 1024
    [OK] tests/fixtures/PersistBlockTests/block1431916.json

These tests use 13.07 MB of stack to run, and so crash with the default stack
limit on Ubuntu Server 20.04 (8MB).  Exactly 12768 bytes per EVM call stack
frame.

    $ rm -f build/all_tests && make ENABLE_EVMC=1 test
    $ ulimit -S -s 16384 # Requires larger stack than default.
    $ ./build/all_tests 7 | tee tlog
    [Suite] new generalstate json tests
        ...
    Stack range 14384 depthHigh 2
        ...
    Stack range 3495456 depthHigh 457
    [OK] tests/fixtures/eth_tests/GeneralStateTests/stRandom2/randomStatetest639.json
    ...
    Stack range 3709600 depthHigh 485
    [OK] tests/fixtures/eth_tests/GeneralStateTests/stRandom2/randomStatetest458.json
        ...
    Stack range 7831600 depthHigh 1024
    [OK] tests/fixtures/eth_tests/GeneralStateTests/stCreate2/Create2OnDepth1024.json

These tests use 7.83MB of stack to run.  About 7648 bytes per EVM call stack
frame.  It _only just_ avoids crashing with the default Ubuntu Server stack
limit of 8 MB.  However, it still crashes on Windows x86-64, which is why the
Windows CI EVMC target is currently disabled.

On Linux where this passes, this is so borderline that it affects work and
testing of the complex storage code, because that's called from the EVM.

Also, this greatly exceeds the default thread stack size.

Measurements after
==================

    $ rm -f build/all_tests && make ENABLE_EVMC=1 test
    $ ulimit -S -s 600 # Because we can!  600k stack.
    $ ./build/all_tests 9 | tee tlog
    [Suite] persist block json tests
    ...
    Stack range 1936 depthHigh 3
    ...
        Stack range 556272 depthHigh 1022
        Stack range 556512 depthHigh 1023
        Stack range 556816 depthHigh 1023
        Stack range 557056 depthHigh 1024
        Stack range 557360 depthHigh 1024
        [OK] tests/fixtures/PersistBlockTests/block1431916.json

    $ rm -f build/all_tests && make ENABLE_EVMC=1 test
    $ ulimit -S -s 600 # Because we can!  600k stack.
    $ ./build/all_tests 7 | tee tlog
    [Suite] new generalstate json tests
        ...
    Stack range 1392 depthHigh 2
        ...
    Stack range 248912 depthHigh 457
    [OK] tests/fixtures/eth_tests/GeneralStateTests/stRandom2/randomStatetest639.json
    ...
    Stack range 264144 depthHigh 485
    [OK] tests/fixtures/eth_tests/GeneralStateTests/stRandom2/randomStatetest458.json
        ...
        Stack range 557360 depthHigh 1024
    [OK] tests/fixtures/eth_tests/GeneralStateTests/stStaticCall/static_CallRecursiveBombPreCall.json

For both tests, a satisfying *544 bytes* per EVM call stack frame, and EVM
takes less than 600 kB total.  With other overheads, both tests run in 600 kB
stack total at maximum EVM depth.

We must add some headroom on this for database activity called from the EVM,
and different compile targets.  But it means the EVM itself is no longer a
stack burden.

This is much smaller than the default thread stack size on Linux (2MB), with
plenty of margin.  (Just fyi, it isn't smaller than a _small_ thread stack on
Linux from a long time ago (128kB), and some small embedded C targets.)

This size is well suited to running EVMs in threads.

Further reduction
=================

This patch solves the stack problem.  Windows and Linux 64-bit EVMC CI targets
can be re-enabled, and there is no longer a problem with stack usage.

We can reduce further to ~340 bytes per frame and 350 kB total, while still
complying with EVMC.  But as this involves changing how errors are handled to
comply fully with EVMC, and removing `dispose` calls, it's not worth doing now
while there are other EVMC changes in progress that will have the same effect.

A Nimbus-specific extension will allow us to avoid recursion with EVMC anyway,
bringing bytes per frame to zero.  We need the extension anyway, to support
Chronos `async` which parallel transaction processing is built around.

Interop with non-Nimbus over EVMC won't let us avoid recursion, but then we
can't control the stack frame size either.  To prevent stack overflow in
interop I anticipate using (this method in Aleth)
[6e96ce34e3/libethereum/ExtVM.cpp (L61)].

Smoke test other versions of GCC and Clang/LLVM
===============================================

As all builds including Windows use GCC or Apple's Clang/LLVM, this is just to
verify we're in the right ballpark on all targets.  I've only checked `x86_64`
though, not 32-bit, and not ARM.

It's interesting to see GCC 10 uses less stack.  This is because it optimises
`struct` returns better, sometimes skipping an intermediate copy.  Here it
benefits the EVMC API, but I found GCC 10 also improves the larger stack usage
of the rest of `nimbus-eth1` as well.

Apple clang 12.0.0 (clang-1200.0.26.2) on MacOS 10.15:

- 544 bytes per EVM call stack frame

GCC 10.3.0 (Ubuntu 10.3.0-1ubuntu1) on Ubuntu 21.04:

- 464 bytes per EVM call stack frame

GCC 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04) on Ubuntu 20.04 LTS:

- 464 bytes per EVM call stack frame

GCC 11.0.1 20210417 (experimental; Ubuntu 11-20210417-1ubuntu1) on Ubuntu 21.04:

- 8 bytes per EVM call stack frame

GCC 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) on Ubuntu 20.04 LTS:

- 544 bytes per EVM call stack frame

GCC 8.4.0 (Ubuntu 8.4.0-3ubuntu2) on Ubuntu 20.04 LTS:

- 544 bytes per EVM call stack frame

GCC 7.5.0 (Ubuntu 7.5.0-6ubuntu2) on Ubuntu 20.04 LTS:

- 544 bytes per EVM call stack frame

GCC 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2) on Ubuntu 19.10:

- 528 bytes per EVM call stack frame

Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-04-27 05:53:32 +01:00
kdeme 769228418e Remove wakunode and waku rpc code from repository 2020-05-07 20:49:14 +03:00
Jacek Sieka d441687488 bump 2020-04-27 18:40:45 +03:00
Ștefan Talpalaru 1694f7097f
add azure-pipelines.yml
- remove redundant flags from nimbus.nimble
- clean up .appveyor.yml comments
2020-04-16 00:34:07 +02:00
Ștefan Talpalaru 8568ec35ea
enable -march=native by default
plus some drive-by fixes and cosmetic changes
2020-02-13 20:18:27 +01:00
Ștefan Talpalaru 06e0eb80e6
lightweight stack traces
Also converted the top-level nim.cfg into a config.nims, in the process.
2020-02-11 04:33:21 +01:00
kdeme a03d0be31f Add start_network.nim to start different types of networks 2020-01-23 12:39:36 +02:00
kdeme 574c5ec0af Add lightNode and logMetrics options 2020-01-23 12:39:36 +02:00
kdeme bcaf6d03ee Add simple example and readme 2020-01-23 12:39:36 +02:00
kdeme 7b80b313e4 Start implementation of waku node 2020-01-23 12:39:36 +02:00
Ștefan Talpalaru fc50c596d1
tests: reduce RAM usage 2019-09-05 19:26:16 +02:00
Jacek Sieka 2763bd0dd5
std_shims -> stew 2019-07-07 12:12:01 +02:00
kdeme 7ab84641d6 Fix, improve and activate rpc test 2019-04-26 13:38:50 +02:00
Ștefan Talpalaru e27cc0c90b
`make test` uses "-d:release" now
also bump vendor/nim-eth, vendor/nim-faststreams
2019-03-31 22:49:32 +02:00
Ștefan Talpalaru 50504cf553 Nimbus: runtime log level selection and logfile option 2019-03-26 13:20:01 +02:00
Ștefan Talpalaru 4326d98434
testsuite: build the tools in parallel 2019-02-28 00:07:23 +01:00
andri lim 14d1c28982 new member of premix tool set 2019-02-27 13:44:01 +02:00
Ștefan Talpalaru e8a6b48904 reorder tests 2019-02-24 10:41:05 +02:00
Ștefan Talpalaru da79a7e996 very simple reproducibility test
Additional changes:
- Makefile verbosity control
- nimble.sh can now run in parallel on the same *.nimble file
- nimble.sh no longer used in the Makefile, in favour of a nimbus.nims
  symlink that eliminates race risks in parallel jobs
- nimbus.nimble takes extra params in the command line, with the caveat
  that they also apply to nim
- setCommand() replaced with exec(), to avoid splitting param strings
2019-02-24 10:41:05 +02:00
Ștefan Talpalaru 44a88bbf4c use "nim" instead of "nimble" to run *.nimble tasks 2019-02-24 10:41:05 +02:00
andri lim 1bc8f41b87 emergency fix #239 2019-02-23 17:57:53 +02:00
andri lim fa183e3a31 separate test_rpc from all_tests 2019-02-20 15:16:07 +02:00
Mamy Ratsimbazafy e1812eb7ce
Prepare for AD2 rebranding to chronos (#225)
* Prepare for AD2 rebranding to chronos - https://github.com/status-im/nim-asyncdispatch2/pull/20

* fix nimble path to chronos

* nim-eth and nim-chronos merged into nimble packages

* fix nimble package name
2019-02-06 19:03:36 +01:00
andri lim 4466deff37 fixes path in tests 2019-02-06 18:42:03 +01:00
Yuriy Glukhov 481c6cf4ed Use nim-eth (#224) 2019-02-05 20:15:50 +01:00
Ștefan Talpalaru ede45648e7 Premix-related changes
- build all tools using the Makefile and place them in ./build
- add copyright header to Makefile
- premix/readme.md edited to fix some errors, improve descriptions and
  document Makefile usage
- link the Premix documentation in the main README.md
- also build `hunter` in the nimble tests
- refactored the file and directory search so all debugging tools can be run
  from the top-level dir like this: `./build/<tool> ...`
- write all JSON debugging data in the current directory
- add JSON files generated in the top-level dir to .gitignore
- Nimbus now exits with an exception after dumping debug data and
  running `premix` on it
2019-01-28 12:38:23 +02:00
andri lim f1bb0d1b31 poststate processing 2019-01-15 15:30:25 +02:00
andri lim 9ab860a00d fixes nimbus.nimble 2019-01-15 15:30:25 +02:00
andri lim f855d73cf2 update nimbus.nimble 2019-01-15 15:30:25 +02:00
Ștefan Talpalaru bd9d15d947 new build system
- isolate dependencies (both Git repos and ".nimble" dir) in "vendor"
- ensure that everything is compiled using our version of Nim with
  something as simple as "make"
- pull the latest changes with "make update"
- re-create Nimble's package dir and re-build the Nim compiler automatically when needed
- "env.sh" script that can be used to prefix any command that needs to use
  "nim" or "nimble" from our Nim repo
- move the top level nim.cfg to nimbus/nim.cfg so it doesn't apply to
  deps
- "fetch-dlls" `make` target for Windows to get precompiled Snappy, RocksDB and SQLite DLLs
2019-01-09 14:25:00 +02:00
andri lim ad1202f98a initial make_receipt 2018-12-16 15:38:51 +02:00
Ștefan Talpalaru 03ec65487d
logging changes
- port some "echo" logging to "chronicles"
- change the logging level of messages that should not appear by default
  to TRACE instead of DEBUG
- remove the "nimbusTrace" define
- suppress logging for messages below the ERROR level in "nimble test"
2018-12-07 00:45:52 +01:00
cheatfate 0b15b86195 Fix ecMul, ecPairing, ecAdd. 2018-10-16 11:49:13 +03:00
cheatfate 9318ea93cf Added nim-bncurve dependency.
Added implementation of `ecAdd`, `ecMul`, `ecPairing` precompiles.
2018-10-05 12:15:04 +03:00
Zahary Karadjov 4e323df363 Implement a --datadir command-line options
By default, the database files will be written in the
platform-specific application data folder:

$HOME/AppData/Roaming/Nimbus/DB
$HOME/Library/Application Support/Nimbus/DB
$HOME/.cache/nimbus/db
2018-09-25 02:06:20 +03:00
Jacek Sieka 0442cbcfbe
nimble: cleanup nimcache and experimental 2018-09-20 12:58:33 -06:00
Zahary Karadjov f84b3c337c Don't use HTTP dependencies in Nimble due to nim-lang/nimble#543 2018-09-16 00:08:29 +03:00
Mamy Ratsimbazafy 18e93903c9
Add the new experimental forloopmacros flag for Stint fix #109 (#110)
* Add the new experimental forloopmacros flag for Stint

* Use a .nimble switch instead of .cfg
2018-08-20 16:13:32 +02:00