Commit Graph

75 Commits

Author SHA1 Message Date
jangko c9cfebfa97
config: rearrange getConfiguration usage
avoid using getConfiguration inside object construction and
replace it with passing suitable param
2021-09-08 08:07:10 +07:00
jangko 9108301eef
config: remove global rng from NimbusConfiguration
move the rng to EthContext
2021-09-07 22:02:29 +07:00
jangko 7dbc44f88c
implement simple PoA sealing engine
the goal of this module is to pass hive/smoke/clique test
and also support for hive/ethereum/rpc test

fixes #801
2021-08-24 14:49:13 +07:00
bmoo b09ad5cacb
code cleanup removed unused imports 2021-08-18 10:35:36 +07:00
jangko 77092641b5
add websocket rpc server 2021-08-06 07:32:19 +07:00
Jordan Hrycaj ca07c40a48
Fearture/poa clique tuning (#765)
* Provide API

details:
  API is bundled via clique.nim.

* Set extraValidation as default for PoA chains

why:
  This triggers consensus verification and an update of the list
  of authorised signers. These signers are integral part of the
  PoA block chain.

todo:
  Option argument to control validation for the nimbus binary.

* Fix snapshot state block number

why:
  Using sub-sequence here, so the len() function was wrong.

* Optional start where block verification begins

why:
  Can speed up time building loading initial parts of block chain. For
  PoA, this allows to prove & test that authorised signers can be
  (correctly) calculated starting at any point on the block chain.

todo:
  On Goerli around blocks #193537..#197568, processing time increases
  disproportionally -- needs to be understand

* For Clique test, get old grouping back (7 transactions per log entry)

why:
  Forgot to change back after troubleshooting

* Fix field/function/module-name misunderstanding

why:
  Make compilation work

* Use eth_types.blockHash() rather than utils.hash() in Clique modules

why:
  Prefer lib module

* Dissolve snapshot_misc.nim

details:
  .. into clique_verify.nim (the other source file clique_unused.nim
  is inactive)

* Hide unused AsyncLock in Clique descriptor

details:
  Unused here but was part of the Go reference implementation

* Remove fakeDiff flag from Clique descriptor

details:
  This flag was a kludge in the Go reference implementation used for the
  canonical tests. The tests have been adapted so there is no need for
  the fakeDiff flag and its implementation.

* Not observing minimum distance from epoch sync point

why:
  For compiling PoA state, the go implementation will walk back to the
  epoch header with at least 90000 blocks apart from the current header
  in the absence of other synchronisation points.

  Here just the nearest epoch header is used. The assumption is that all
  the checkpoints before have been vetted already regardless of the
  current branch.

details:
  The behaviour of using the nearest vs the minimum distance epoch is
  controlled by a flag and can be changed at run time.

* Analysing processing time (patch adds some debugging/visualisation support)

why:
  At the first half million blocks of the Goerli replay, blocks on the
  interval #194854..#196224 take exceptionally long to process, but not
  due to PoA processing.

details:
  It turns out that much time is spent in p2p/excecutor.processBlock()
  where the elapsed transaction execution time is significantly greater
  for many of these blocks.

  Between the 1371 blocks #194854..#196224 there are 223 blocks with more
  than 1/2 seconds execution time whereas there are only 4 such blocks
  before and 13 such after this range up to #504192.

* fix debugging symbol in clique_desc (causes CI failing)

* Fixing canonical reference tests

why:
  Two errors were introduced earlier but ovelooked:
   1. "Remove fakeDiff flag .." patch was incomplete
   2. "Not observing minimum distance .." introduced problem w/tests 23/24

details:
  Fixing 2. needed to revert the behaviour by setting the
  applySnapsMinBacklog flag for the Clique descriptor. Also a new
  test was added to lock the new behaviour.

* Remove cruft

why:
  Clique/PoA processing was intended to take place somewhere in
  executor/process_block.processBlock() but was decided later to run
  from chain/persist_block.persistBlock() instead.

* Update API comment

* ditto
2021-07-30 15:06:51 +01:00
Jamie Lokier c435409292
Sync: Move `blockchain_sync` code and use it with `eth/65`
Move `blockchain_sync.nim` from `nim-eth` to `nimbus-eth1`.

This lets `blockchain_sync` use the `eth/65` protocol to synchronise with more
modern peers than before.

Practically, the effect is the sync process runs more quickly and reliably than
before.  It finds usable peers, and they are up to date.

Note, this is mostly old code, and it mostly performs "classic sync", the
original Ethereum method.  Here's a summary of this code:

- It decides on a blockchain canonical head by sampling a few peers.
- Starting from block 0 (genesis), it downloads each block header and
  block, mostly in order.
- After it downloads each block, it executes the EVM transactions in that block
  and updates state trie from that, before going to the next block.
- This way the database state is updated by EVM executions in block order,
  and new state is persisted to the trie database after each block.

Even though it mentions Geth "fast sync" (comments near end of file), and has
some elements, it isn't really.  The most obvious missing part is this code
_doesn't download a state trie_, it calculates all state from block 0.
Geth "fast sync" has several parts:

1. Find an agreed common chain among several peers to treat as probably secure,
   and a sufficiently long suffix to provide "statistical economic consensus"
   when it is validated.
2. Perform a subset of PoW calculations, skipping forward over a segment to
   verify some of the PoWs according to a pattern in the relevant paper.
3. Download the state trie from the block at the start of that last segment.
4. Execute only the blocks/transactions in that last segment, using the
   downloaded state trie, to fill out the later states and properly validate the
   blocks in the last segment.

Some other issues with `blockchain_sync` code:

- If it ever reaches the head of the chain, it doesn't follow new blocks with
  increasing block numbers, at least not rapidly.
- If the chain undergoes a reorg, this code won't fetch a block number it has
  already fetched, so it can't accept the reorg.  It will end up conflicted
  with peers. This hasn't mattered because the development focus has been on
  the bulk of the catching up process, not the real-time head and reorgs.
- So it probably doesn't work correctly when it gets close to the head due to
  many small reorgs, though it might for subtle reasons.
- Some of the network message handling isn't sufficiently robust, and it
  discards some replies that have valid data according to specification.
- On rare occasions the initial query mapping block hash to number can
  fail (because the peer's state changes).
- It makes some assumptions about the state of peers based on their responses
  which may not be valid (I'm not convinced they are).  The method for working
  out "trusted" peers that agree a common chain prefix is clever.  It compares
  peers by asking each peer if it has the header matching another peer's
  canonical head block by hash.  But it's not clear that merely knowing about a
  block constitutes agreement about the canonical chain.  (If it did, query by
  block number would give the same answer more authoritatively.)

Nonetheless, being able to run this sync process on `eth/65` is useful.

<# interactive rebase in progress; onto 66532e8a

Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-07-27 14:12:53 +01:00
Jamie Lokier 00647b373c
Sync: Switch other modules over to the `eth/65` module
Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-07-27 14:12:41 +01:00
Jamie Lokier 613f06e61c
Whisper: Remove all the main Whisper code (config, startup, RPC etc)
This is the main patch which removes Whisper code from `nimbus-eth1` code.
It removes all configuration, help, startup, JSON-RPC calls and most types.

Note, there is still Whisper functionality in `nim-eth`.  Also, the "wrapper"
under `wrappers/` isn't dealt with by this change, but it's not built by
default (and might not currently work).

Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-06-01 18:12:48 +01:00
Jamie Lokier f5c69f372a
Whisper: Remove all code which starts Whisper running
This is the patch which removes Whisper functionality from `nimbus-eth1`,
even though the code has yet to be removed after.

After this change, enabling Whisper has no effect.  Its configuration is
ignored and it won't be started.

Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-06-01 18:12:48 +01:00
jangko b82061bf46
don't mix customBootNodes and bootNodes usage 2021-05-20 14:04:17 +07:00
jangko a0d10f5728
drop PublicNetwork enum usage and replace it with NetworkId
we cannot limit the `--networkid` switch to values available in
`PublicNetwork` enum. it should able to accept very wide range of
custom NetworkId.
2021-05-20 14:04:16 +07:00
jangko d2b47139e1
fixes `importRlpBlocks` in conf_utils.nim
now we are importing block one by one to satisfy
some of hive test cases.

we also catch exception instead of letting it terminate the
process.
2021-05-17 18:43:44 +07:00
Jordan Hrycaj 59d7ba1f1e print compiler warning about the VM used
why:
  handy to have confirmation about which of the three different VMs
  is activated
2021-04-28 15:24:14 +03:00
jangko 103996f6b2
integrate graphql service into nimbus-eth1 2021-04-24 11:01:09 +07:00
Jacek Sieka 3147df0dcd
switch to chronos metrics, remove insecure (#580)
* switch to chronos metrics, remove insecure

See https://github.com/status-im/nimbus-eth2/pull/2468

also fixes pcre linking for real, and adds some random build flags that
help nimbus-eth2 stay afloat

* fix help

* don't omit frame pointers on windows
2021-04-09 09:26:06 +02:00
kdeme f34431e2d4
Bump nim-eth and nim-chronos and fix exception effects 2021-04-02 19:55:21 +02:00
jangko 2cd081495b implement '--import': import rlp encoded block(s), validate, write to db and quit 2021-03-23 10:37:00 +07:00
jangko d200a98a68
fix compilation error 2020-07-23 16:01:19 +07:00
jangko f82dff64fa
implement more eth rpc and keystore management 2020-07-23 14:54:32 +07:00
jangko 336efdb0c3
implement web3, net, and some eth namespace rpc 2020-07-22 23:57:55 +07:00
jangko 04dcec03a3
fix missing import when chronicles enabled 2020-07-21 15:12:59 +07:00
jangko 207065746c
reduce more warnings 2020-07-21 13:25:27 +07:00
jangko 12ddfee675
fix compilation error related to lib-secp256k1 changes 2020-06-24 17:07:33 +07:00
Ștefan Talpalaru cf2a6fb621
small NimbusState refactoring 2020-05-21 03:33:11 +02:00
Jacek Sieka 4ade5797ee
rlp: don't use ranges / experimental features (#495) 2020-04-20 20:12:44 +02:00
Ștefan Talpalaru af89b51503
Merge branch 'master' into nim-1.2 2020-04-08 20:16:37 +02:00
Jacek Sieka 1d472cf090
Eth keys (#482)
* bump nim-eth, fix deprecated calls
2020-04-05 15:12:48 +02:00
Zahary Karadjov 3fc3ba925e
Compile Nimbus with Nim 1.2 2020-04-03 22:09:14 +03:00
kdeme d56655d278 Move WhisperKeys to KeyStorage 2020-01-23 12:39:36 +02:00
acolytec3 45cda8bab0 Add support for custom genesis blocks 2020-01-20 06:35:35 -05:00
kdeme 9964a55772 Replace getCurrentException 2019-12-05 13:02:21 +01:00
Ștefan Talpalaru 356a7cad84
show a message on Ctrl+C 2019-07-20 01:40:31 +02:00
Ștefan Talpalaru 409d771a50 metrics: put the HTTP server under -d:insecure
- also fix an option parsing bug
- bump vendor/nim-eth and vendor/nim-metrics
2019-07-19 15:17:51 +03:00
Ștefan Talpalaru 0f3d05bf68 metrics: HTTP server disabled by default
- metric logging added
- new Nimbus options: --metricsServer, --metricsServerPort:<value>,
  --logMetrics, --logMetricsInterval:<value>
2019-07-19 15:17:51 +03:00
Ștefan Talpalaru 2d9f62530b metrics HTTP server replacing the periodic "stats" logging
and example prometheus.yml file to use it as a scraping target
2019-07-19 15:17:51 +03:00
Ștefan Talpalaru 50095ae22f
macOS fix 2019-07-11 00:38:25 +02:00
Ștefan Talpalaru 06ab21e8c5
Ctrl+C handling for a graceful stop
addSignal() doesn't seem to work, which is probably why it was commented
out. I'm using setControlCHook() instead, moved at an earlier point in the
start-up process, but its handler can only change global variables, so I
had to make "nimbus" global.
2019-07-10 23:23:11 +02:00
Ștefan Talpalaru 5ee668516a
add nim-metrics 2019-07-10 16:32:44 +02:00
Ștefan Talpalaru b71ce17ac3
periodically log internal statistics
and bump submodules
2019-06-26 16:32:01 +02:00
kdeme 46a9d8e79d Forward maxPeers config to EthereumNode minPeers 2019-06-24 19:33:52 +03:00
Ștefan Talpalaru ef319483be
log CatchableError in poll() 2019-05-28 12:49:36 +02:00
Ștefan Talpalaru b45e9d5493
don't close stdout when using a log file
also bump vendor/nim-chronicles and vendor/nim-eth
2019-05-08 02:25:04 +02:00
kdeme d43f20c65a Initial implementation of Whisper RPC 2019-04-26 13:38:50 +02:00
kdeme 46fb9dc1b2 Add staticnodes, protocols, and whisper config options (#319) 2019-04-23 07:49:49 -06:00
Ștefan Talpalaru aa29e25c3a
clarify comment 2019-04-18 01:17:06 +02:00
Ștefan Talpalaru d4aff04cbd
NAT port mapping 2019-04-17 03:56:28 +02:00
andri lim 8a9e4aba80
apply dao fork changes 2019-04-07 06:53:26 +07:00
Ștefan Talpalaru 50504cf553 Nimbus: runtime log level selection and logfile option 2019-03-26 13:20:01 +02:00
Ștefan Talpalaru a67edd693a
assert() -> doAssert() 2019-03-13 22:36:54 +01:00