Commit Graph

2593 Commits

Author SHA1 Message Date
Jacek Sieka 1a9e9fc398
use LTO in release builds (#1661)
* use LTO in release builds

This significantly (40%) speeds up block replay and hashing - for example replaying first 1000
blocks, without/with LTO:

```
[arnetheduck@tempus ncli]$ ../env.sh nim c -d:release ncli_db
[arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000
Loaded 215006 blocks, head slot 307400
All time are ms
     Average,       StdDev,          Min,          Max,      Samples,         Test
Validation is turned off meaning that no BLS operations are performed
   25468.481,        0.000,    25468.481,    25468.481,            1, Initialize DB
       0.297,        0.516,        0.053,       13.645,          721, Load block from database
      26.458,        0.000,       26.458,       26.458,            1, Load state from database
      20.737,        8.288,       11.096,      199.325,          690, Apply block
     333.069,       62.798,       45.225,      429.452,           31, Apply epoch block
       0.000,        0.000,        0.000,        0.000,            0, Database block store
```

```
[arnetheduck@tempus ncli]$ ../env.sh nim c -d:release --passc:-flto --passl:-flto --stacktrace:off ncli_db
[arnetheduck@tempus ncli]$ ./ncli_db bench --db:db --network:medalla --slots:1000
Loaded 215006 blocks, head slot 307400
All time are ms
     Average,       StdDev,          Min,          Max,      Samples,         Test
Validation is turned off meaning that no BLS operations are performed
   23903.006,        0.000,    23903.006,    23903.006,            1, Initialize DB
       0.253,        0.122,        0.047,        0.731,          721, Load block from database
      24.455,        0.000,       24.455,       24.455,            1, Load state from database
      18.734,        7.062,       10.346,      167.397,          690, Apply block
     194.869,       33.175,       29.311,      226.981,           31, Apply epoch block
```

Epoch processing is heavy on both arithmetics and hash caching, both of which get a
significant boost here.

This makes sense: nim creates lots of small functions spread out over many C files. A much
worse solution is to try to annotate code with `inline` - it copies functions to multiple
C files but still doesn't do intermodule optimizations significantly limiting the
compilers' ability to reason about the code, causing bloat and misrepresenting the usefulness
of a function to the call frequency analysis that drives actual (C-compiler) inlining and many
other optimizations.

In particular, many nim functions are part of `system` or the `C` backend - stack tracing,
memory allocation etc - nim's inlining system is pretty incomplete in that it does not deal
with these and many other cases.

* windows workaround

* skip LTO on windows for now
2020-09-24 18:40:28 +02:00
tersec 0eb53f2802
avoid unpacking phase 1 tests to reduce Azure CI disk usage (#1736) 2020-09-24 17:16:00 +02:00
Viktor Kirilov 410a72667b fixed interop with geth after updating nim-web3 2020-09-24 16:07:57 +03:00
Eugene Kabanov 2cd0c3adaa
Fix condition. (#1734) 2020-09-24 14:14:29 +02:00
Mamy Ratsimbazafy 1f5b487fc6
Github Actions CI (#1693)
* Clean up PR + bump nimbus-build-system

* pcre on 32-bit + Improve env variable handling + cache mingw

* Add badge + fix setting env variable

* Auto cancel if commit becomes outdated

* fix shell for deriving env variable

* Add more cancellation points

* Add finalization tests to Github Action

* Fix case

* change cancel actions + fixes for windows and finalization

* have to use matrix variable for cache path/key

* ARCH_OVERRIDE=LATFORM issue rebuild cache

* Update scripts - deactivate workflows with identified issues + reactivate caching

* workaround mac getopt

* Disable all aAVX512f extensions (Error: invalid register for .seh_savexmm in Cygwin)

* Fix cross compile of libminiupmp #1723

* Cache fetch-dlls to avoid being a drag on nim-lang.org

* Fix windows downloading DLLs twice and set CFLAGS env variable for Linux32

* fix silly yaml mistake

* .

* reactivate win32 after https://github.com/status-im/nim-beacon-chain/pull/1726

* Comment out minimal tests for now
2020-09-24 13:45:34 +02:00
Viktor Kirilov b9deff43ce fixed build after rebasing on top of the recently introduced slashing protection 2020-09-24 11:31:14 +03:00
Viktor Kirilov e926db22b9 initial implementation of attestation aggregation for the validator API 2020-09-24 11:31:14 +03:00
nbc-bump-bot[bot] 4ded755d32
auto-bump nim-libp2p (#1732)
Co-authored-by: = <arnetheduck@users.noreply.github.com>
2020-09-24 09:57:15 +02:00
Jacek Sieka f0dbebfd3f
avoid storing empty slot states (#1720)
with the improved empty slot processing, these provide relatively little
benefit, but take up lots of storage that's difficult to free
2020-09-24 09:02:03 +02:00
Mamy Ratsimbazafy 4e23b0ef23
Fix https://github.com/status-im/nim-beacon-chain/issues/1701 + raise concerns in keystore secrets protection (#1726) 2020-09-24 07:27:56 +02:00
nbc-bump-bot[bot] d7bfef3c78
auto-bump nim-libp2p (#1711)
Co-authored-by: = <arnetheduck@users.noreply.github.com>
2020-09-24 07:26:56 +02:00
Eugene Kabanov 08795b3f5d
Fix tight loop at the end of sync process. (#1731) 2020-09-23 17:58:02 +02:00
yslcrypto 2bc26940d4 update introduction 2020-09-23 15:50:19 +02:00
yslcrypto a84a65bcbe grammar fix 2020-09-23 15:38:35 +02:00
yslcrypto 9613af3391 nimbus book, metric page: integrate feedback 2020-09-23 15:33:20 +02:00
yslcrypto 72c0a3a763 metrics and pretty pictures 2020-09-23 14:26:42 +02:00
Jacek Sieka e1c177cdd1
bump libp2p (#1721)
gossipsub 1.1 can be enabled with -d:nbc_gossipsub_11
2020-09-22 19:34:34 +02:00
Zahary Karadjov 73724b2c4b Add attacknet-beta1-mc-0 2020-09-22 18:51:51 +03:00
Zahary Karadjov 10cfd1ec37 Adds the Spedina testnet; Upgrades the spec presets to spec v0.12.3
Other changes:

* Removed all references to Altona
* Refactored the Makefile to avoid code duplication
2020-09-22 18:51:51 +03:00
Sacha Saint-Leger f8733a4fb6
Update faq.md (#1717)
* Update faq.md

* Update docs/the_nimbus_book/src/faq.md

Co-authored-by: Jacek Sieka <jacek@status.im>

Co-authored-by: Jacek Sieka <jacek@status.im>
2020-09-21 22:11:56 +02:00
Eugene Kabanov 654b8d66bf
Peer management (#1707)
* addPeer() and addPeerNoWait() now returns PeerStatus, not bool.
Minor refactoring of PeerPool.
Fix tests.

* Refactor PeerPool.
Add lenSpace.
Add tests for lenSpace.
PeerPool.add procedures now return different error codes.
Fix SyncManager break/continue problem.
Fix connectWorker break/continue problem.
Refactor connectWorker and discoveryLoop.
Fix incoming/outgoing blocking problem.

* Refactor discovery loop.
Add checkPeer.

* Fix logic and compilation bugs.

* Adjust position of debugging log.

* Fix issue with maximum peers in PeerPool.
Optimize node record decoding.

* fix discoveryLoop.

* Remove aliases and fix tests using aliases.
2020-09-21 18:02:27 +02:00
tersec 3190c695b0
minimal v0.12.3 update (#1716) 2020-09-21 15:58:35 +00:00
Sacha Saint-Leger 3c6f6115eb
Update medalla-troubleshooting.md (#1705)
add section addressing `address already in use error`. we already sort of cover this in the guide, but i think it makes sense to have it explicitly mentioned here.
2020-09-21 15:21:36 +02:00
Jacek Sieka f8e782fb5f
bump nim-eth (#1708)
fixes WAL file growth in sqlite - might cause nbc to freeze once for a
minute or two while clearing the wal
2020-09-21 11:07:59 +02:00
Mamy André-Ratsimbazafy c1413899f5
Merge remote-tracking branch 'origin/master' into devel 2020-09-21 09:34:51 +02:00
Jacek Sieka 59a3862f6f
bump nim-stew, get bitops intrinsics 2020-09-21 08:46:29 +02:00
Ștefan Talpalaru 4c51eee7f9
USE_LIBBACKTRACE=0: speed up compilation by 3.31% (#1686)
* USE_LIBBACKTRACE=0: speed up compilation by 3.31%

* USE_LIBBACKTRACE=0: no line numbers in stack traces; blame Jacek
2020-09-21 08:40:01 +02:00
Ștefan Talpalaru 2b6c287dbb
update: delete "nimcache" dirs (#1706) 2020-09-21 08:39:13 +02:00
yslcrypto 13edb40f46 link to ubuntu guide 2020-09-20 13:49:05 +02:00
Jacek Sieka fc10f5121a protect against data after initial request
spec requires that channel is closed

also, avoid some unnecessary futures
2020-09-18 21:34:07 +03:00
zah 7c688bffda
Address #1586 (#1596) 2020-09-18 18:34:13 +02:00
Mamy Ratsimbazafy ea4ec6a785
Upgrade blst (#1682)
* Bump BLST

* Test for https://github.com/supranational/blst/issues/22 regression

* Use SHA256 from BLST + bump nim-blscurve to reenable fno-tree-vectorize

* SHA256 on non-blst platforms import fixes

* import fixes again

* can't prefix with nimcrypto

* address review comment [skip ci]

* {.noInit.} on the digests
2020-09-18 16:55:55 +02:00
tersec e106549efe
keep REJECT/IGNORE of messages failing validation for libp2p scoring (#1676)
* keep REJECT/IGNORE status of messages failing validation for libp2p scoring

* fix test suite
2020-09-18 13:53:09 +02:00
Jacek Sieka 000a0ecc52
initial e2store file format description (#1355)
This is one way we could organize the flat file storage for blocks - the
alternative would be to not do `type` in the file itself, but have a
single type per file which arguably is simpler but may become annoying.

Another potential restriction would be to require that blocks are
ordered - with this format, it's a little bit more involved to recreate
an index file, and it's easy to accidentally build in assumptions about
the block order in the main data file.
2020-09-17 23:23:54 +02:00
Sacha Saint-Leger e4b4b29320
Update medalla.md (#1685)
minor edits + clarifications
2020-09-17 20:25:21 +02:00
Sacha Saint-Leger 4c0bdffd4c
Update medalla.md (#1681)
explain syncv2 string and terminal status bar
2020-09-17 18:39:49 +02:00
Dmitriy Ryajov 2f89e2ab4e
drop subscribePeer, it's called from pubsub now (#1677) 2020-09-17 11:40:21 +02:00
Sacha Saint-Leger 6bde3b85a7
Book edits: master is now the preferred branch (#1675)
* Update medalla.md

remove `cd devel`

* Update medalla-troubleshooting.md

edits to make clear that master is now the recommended branch
2020-09-17 00:26:51 +02:00
Jacek Sieka dcf8a6b05d
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)

tests using a recent medalla state and advancing it 1000 slots:

```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:

```

All time are ms
Average,       StdDev,          Min,          Max,      Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236,        0.000,       39.236,       39.236,            1,
Load state from file
0.049,        0.002,        0.046,        0.063,          968,
Apply slot
256.504,       81.008,      213.471,      591.902,           32,
Apply epoch slot
28.597,        0.000,       28.597,       28.597,            1,
Save state to file
```

cast:
```
All time are ms
Average,       StdDev,          Min,          Max,      Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079,        0.000,       37.079,       37.079,            1,
Load state from file
0.042,        0.002,        0.040,        0.090,          968,
Apply slot
215.552,       68.763,      180.155,      500.103,           32,
Apply epoch slot
25.106,        0.000,       25.106,       25.106,            1,
Save state to file
```

cast+rewards:
```
All time are ms
Average,       StdDev,          Min,          Max,      Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049,        0.000,       40.049,       40.049,            1,
Load state from file
0.048,        0.001,        0.045,        0.060,          968,
Apply slot
164.981,       76.273,      142.099,      477.868,           32,
Apply epoch slot
28.498,        0.000,       28.498,       28.498,            1,
Save state to file
```

cast+rewards+shr
```
All time are ms
Average,       StdDev,          Min,          Max,      Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898,        0.000,       12.898,       12.898,            1,
Load state from file
0.039,        0.002,        0.038,        0.054,          968,
Apply slot
139.971,       68.797,      120.088,      428.844,           32,
Apply epoch slot
24.761,        0.000,       24.761,       24.761,            1,
Save state to file

```
2020-09-16 20:59:33 +00:00
Ștefan Talpalaru 4b38619c4f better handling of Ctrl+C during `make update` (#1588) 2020-09-16 19:21:59 +02:00
nbc-bump-bot[bot] f901c8d55a auto-bump nim-libp2p (#1659)
Co-authored-by: = <arnetheduck@users.noreply.github.com>
2020-09-16 19:21:59 +02:00
Mamy Ratsimbazafy 702b346965 Opt-in Slashing protection + interchange (#1643)
* Slashing protection + interchange initial commit

* Restrict the when UseSlashingProtection dance in other modules

* Integrate slashing tests in other all_tests

* Add attestation slashing protection support

* Add a message that mention if built with/without slashing protection

* no op the initialization proc

* test slashing protection in Jenkins (temp)

* where to configure NIMFLAGS in Jenkins ...

* Jenkins -> ensure Built with slashing protection

* Add slashing protection complete import

* use Opt.get(otherwise)

* Don't use negation in proc name

* Turn slashing protection on by default
2020-09-16 19:21:59 +02:00
Eugene Kabanov 8b492ed1ce PeerPool fixes. (#1654)
* Refactor peer_pool.
Fix eth2_network peer counters.
Fix PeerPool do not allow to add more peers when empty space available.

* Remove unused imports.

* Add test for a bug.

* Fix eth2_network disconnect should deletePeer not release.
More PeerPool refactoring.
2020-09-16 19:21:59 +02:00
tersec 67f3bd203e close block_sim database; remove code duplication in exit_pool (#1656) 2020-09-16 19:21:59 +02:00
Eugene Kabanov 66ba5d072a Fix sync_manager.nim not rewarding peers for good responses. (#1660) 2020-09-16 19:21:59 +02:00
nbc-bump-bot[bot] 3f129d06dc auto-bump nim-libp2p (#1606)
Co-authored-by: = <arnetheduck@users.noreply.github.com>
2020-09-16 19:21:59 +02:00
tersec f566a84f5c enable topic unsubscribing and attestation subnet cycling (#1646)
* enable topic unsubscribing and attestation subnet cycling

* remove refences to states

* waitFor -> await

* revert exit pool changes for a cleaner PR
2020-09-16 19:21:59 +02:00
Eugene Kabanov 0b029220ee Bump chronos to fix memory leaks. (#1648) 2020-09-16 19:21:59 +02:00
Jacek Sieka 20dd38fdf9 fix some todo (#1645)
* remove some superfluous gcsafes
* remove getTailState (unused)
* don't store old epochrefs in blocks
* document attestation pool a bit
* remove `pcs =` cruft from log
2020-09-16 19:21:59 +02:00
tersec 804b152d1d [WIP] skeleton of attester slashing pool & validators (#1639)
* skeleton of attester slashing pool & validators

* add skeleton for proposer slashings and voluntary exits; rename pool to more inclusive exit pool to stay consistent with all three; ensure is initialized by beacon_node so is safe to merge, even if it doesn't do much yet
2020-09-16 19:21:59 +02:00