Commit Graph

4073 Commits

Author SHA1 Message Date
Etan Kissling 7e0e06ee80
X 2022-04-17 14:12:08 +02:00
Etan Kissling ed35d69cef
allow sync using light client protocol
This is a construction site with a proof of concept for syncing with the
proposed light client protocol.
See https://github.com/ethereum/consensus-specs/pull/2802

Note: THINGS ARE STILL BUGGY.

To test, first launch a local testnet:
```
rm -rf local_testnet_data && scripts/launch_local_testnet.sh \
  --kill-old-processes --preset minimal --disable-htop --disable-vc -- \
  --log-format=auto --max-peers=160 --import-light-client-data=full \
  --serve-light-client-data
```

Then, monitor http://127.0.0.1:7500/eth/v1/beacon/headers/finalized
until a slot >= 8 is finalized (Altair fork).

Finally, use a second Terminal to start an additional node to sync with
this testnet using the light client protocol.
```
rm -rf "local_testnet_data/client_$(git rev-parse --abbrev-ref HEAD)"; \
  make -j16 nimbus_beacon_node \
    NIMFLAGS="-d:local_testnet -d:const_preset=minimal" && \
  build/nimbus_beacon_node \
    --nat:extip:127.0.0.1 \
    "--network=local_testnet_data" \
    --tcp-port=9999 --udp-port=9999 --rest-port=5999 \
    "--data-dir=local_testnet_data/client_$(git rev-parse --abbrev-ref HEAD)" \
    "--bootstrap-node=$(curl http://127.0.0.1:7500/eth/v1/node/identity | jq -r .data.enr)" \
    --subscribe-all-subnets --rest --log-level=DEBUG \
    "--light-client-state-node-url=http://127.0.0.1:7500" \
    "--light-client-trusted-block-root=$(curl http://127.0.0.1:7500/eth/v1/beacon/headers/8 | jq -r .data.root)"
```
2022-02-23 13:07:27 +01:00
Etan Kissling caa4477751
Merge branch 'sm-te' into X
* sm-te:
  make `SyncQueue` / `SyncManager` generic
2022-02-18 12:57:25 +01:00
Etan Kissling 1c9e73b274
make `SyncQueue` / `SyncManager` generic
The libp2p light client sync protocol defines an endpoint for syncing
historic data that is structured similarly to `beaconBlocksByRange`,
i.e., it uses a start/count/step tuple to sync from finalized to head.
See https://github.com/ethereum/consensus-specs/pull/2802
As preparation, this patch extends the `SyncQueue` and `SyncManager`
implementations to work with such new `ByRange` endpoints as well.
2022-02-18 12:45:58 +01:00
Etan Kissling ef1048e6a1
serve libp2p protocol for light client sync
This extends the `--serve-light-client-data` launch option to serve
locally collected light client data via libp2p.
Backfill of historic best `LightClientUpdate` is not yet implemented.
See https://github.com/ethereum/consensus-specs/pull/2802

To test, in `conf.nim` change the `defaultValue` of:
- `serveLightClientData` to `true`
- `importLightClientData` to `ImportLightClientData.Full` (or others)
Then, run:
```
scripts/launch_local_testnet.sh --kill-old-processes --preset minimal \
    --nodes 4 --disable-htop --stop-at-epoch 7
```
The log files of the beacon nodes will be in the `local_testnet_data`
directory. They are named `log0.txt` through `log3.txt`. The logs can be
browsed for light client related messages.
2022-02-17 21:40:59 +01:00
Etan Kissling 97b1ed9b38
add option to produce light client data
Light clients require full nodes to serve additional data so that they
can stay in sync with the network. This patch adds a new launch option
`--serve-light-client-data` to enable collection of light client data.
`--import-light-client-data` configures the classes of data to import.
This can be set to `none`, `only-new`, `full`, or `on-demand`.
Note that data is only locally collected, a separate patch is needed to
actually make it availble over the network. Likewise, data is only kept
in memory; it is not persisted at this time.
2022-02-17 15:52:51 +01:00
Etan Kissling a38b6f4c45
update to latest light client sync protocol
This implements the latest version of the light client sync protocol,
and also adds a test runner for the new accompanying tests.
See https://github.com/ethereum/consensus-specs/pull/2802
2022-02-17 10:38:35 +01:00
Ștefan Talpalaru 6e1ad080e8
bump submodules (#3366)
and add Nim-1.6 compatibility
2022-02-16 13:41:50 +02:00
Eugene Kabanov 3a80b9951c
VC: Fix forks handling. (#3389)
* Trying to debug the finalization issue.

* Add debug logs to understand signature issue.

* Remove all the debugging helpers.

* Initial commit.

* Address review comments.

* Remove unneeded checks for empty fork schedule.

* Fix bellatrix ExecutionAddress serialization/deserialization procedures.
2022-02-16 12:31:23 +01:00
tersec 254e0fe2e2
avoid nimZeroMem and stack usage in is_merge_transition_complete and is_merge_transition_block (#3399) 2022-02-16 07:16:01 +00:00
Zahary Karadjov 47a72c474e
Bump ipython (security advisory) 2022-02-15 23:13:23 +02:00
Dustin Brody e1dbcfc02e
add --safe-slots-to-import-optimistically option 2022-02-15 23:08:49 +02:00
Zahary Karadjov 5b13b7cc9b
Merge branch 'stable' into unstable 2022-02-15 22:56:43 +02:00
Zahary Karadjov 8e0330050d
Version 1.7.0 2022-02-15 22:55:29 +02:00
Zahary Karadjov c672628be8 Hotfix: Fix a race condition leading to a busy loop preventing progress in Eth1 syncing 2022-02-15 22:45:55 +02:00
Ștefan Talpalaru 496d0266ec
bump nim-metrics (#3392) 2022-02-14 21:57:06 +01:00
tersec 2275fad335
only show setting up doppelganger detection log message if enabled (#3391)
* only show setting up doppelganger detection log message if enabled

* correct indentation
2022-02-14 19:24:38 +00:00
Etan Kissling 6849536742 fix `firstSlot` computation for backfill sync
When initializing backfill sync, the implementation intends to start at
the first unknown slot (`1` before tail). However, an incorrect variable
is passed, and backfill sync actually starts at the tail slot instead.
This patch corrects this by passing the intended variable. The problem
was introduced with the original backfill implementation at #3263.
2022-02-14 18:53:38 +02:00
Zahary Karadjov 922a0d264c Add CORS support for the REST services
The added options work in opt-in fashion. If they are not specified,
the server will respond to all requests as if the CORS specification
doesn't exist. This will result in errors in CORS-enabled clients.

Please note that future versions may support more than one allowed
origin. The option names will stay the same, but the user will be
able to repeat them on the command line (similar to other options
such as --web3-url).

To be documented in the guide in a separate PR.
2022-02-14 18:52:17 +02:00
sacha e81e67fe65
book updates (#3388) 2022-02-14 12:39:10 +01:00
Etan Kissling d1f97e209a
remove unused `sleepTime` from `SyncManager` (#3384)
The `SyncManager` has a leftover optional `sleepTime` parameter in
its constructor that used to configure the sync loop polling rate.
This parameter was replaced with a constant in #1602 and is no longer
functional. This patch removes the `sleepTime` leftovers.
2022-02-14 12:05:01 +01:00
Etan Kissling a28900c348
fix slot number display during sync (#3383)
#3304 introduced a regression to the sync status string displayed in the
status bar; during the main forward sync, the current slot is no longer
reported and always displays as `0`. This patch corrects the computation
to accurately report the current slot once more.
2022-02-14 12:04:04 +01:00
tersec 873a8ec1e6
use isZeroMemory for Eth2Digest comparisons (#3386)
* use isZeroMemory for Eth2Digest comparisons

* use Eth2Digest.isZero abstraction
2022-02-14 05:26:19 +00:00
Eugene Kabanov 1a0bcf0b02
Fix #3267 (#3367)
* Initial commit.

* One more fix.

* Trying to debug the finalization issue.

* Add debug logs to understand signature issue.

* Restore hash_tree_root calculation.

* Remove all the debugging helpers.

* Add `slot` check.

* Address review comment.
2022-02-13 16:21:55 +01:00
Etan Kissling 15fc7534cf
remove unused `maxStatusAge` from `SyncManager` (#3382)
The `SyncManager` has a leftover optional `maxStatusAge` parameter in
its constructor that used to configure the libp2p `Status` polling rate.
This parameter was replaced with a constant in #1827 and is no longer
functional. This patch removes the `maxStatusAge` leftovers.
2022-02-13 16:17:13 +01:00
tersec 2160d02977
use REST for make pyrmont/prater; use --rest options for local testnet (#3380) 2022-02-12 12:27:43 +01:00
Jacek Sieka 1f89b7f7b9
speed up trusted node backfill (#3371)
With these changes, we can backfill about 400-500 slots/sec, which means
a full backfill of mainnet takes about 2-3h.

However, the CPU is not saturated - neither in server nor in client
meaning that somewhere, there's an artificial inefficiency in the
communication - 16 parallel downloads *should* saturate the CPU.

One plasible cause would be "too many async event loop iterations" per
block request, which would introduce multiple "sleep-like" delays along
the way.

I can push the speed up to 800 slots/sec by increasing parallel
downloads even further, but going after the root cause of the slowness
would be better.

* avoid some unnecessary block copies
* double parallel requests
2022-02-12 12:09:59 +01:00
Jacek Sieka 40fe8f5336 fix missing backfill when restarting node
When node is restarted before backfill has started but after some blocks
have finalized with forward sync, we would not start the backfill.

* also clean up one last `SomeSome`
2022-02-11 23:08:50 +02:00
Jacek Sieka 1760f4d7a7
move wallet/deposit commands to separate files (#3372)
These commands have little to do with the "normal" beacon node operation
- ergo, they deserve to live in their own module.

* clean up imports/exports
2022-02-11 21:40:49 +01:00
Dustin Brody 3daa52ab87
update docs for geth/kiln 2022-02-11 20:06:06 +00:00
tersec d02daf8cbd
bump nim-web3 to fix kiln interop (#3373) 2022-02-11 18:38:44 +00:00
tersec fc0ce57b68
kiln merge test vectors for EL (#3377) 2022-02-11 18:17:37 +00:00
Eugene Kabanov b4eb150b9a
Revert restAccept workaround. (#3369)
Bump fixed version of nim-presto.
2022-02-11 12:01:45 +01:00
Jeremy Schlatter 47b1870100
update prysm export docs (#3365)
This command was [recently renamed](https://github.com/prysmaticlabs/prysm/pull/9873).
2022-02-09 11:25:12 +01:00
Mamy Ratsimbazafy 97a1735e4a
Bump BLST (security fic on currently unused primitive) (#3364) 2022-02-09 03:08:47 +01:00
Ștefan Talpalaru 70b38e37e6
Nim GC metrics for the main thread (#3108)
* Nim GC metrics for the main thread
2022-02-08 20:19:21 +01:00
sacha 2b0957f32a
Update README.md
edit intro; add migration section
2022-02-08 18:41:42 +01:00
yslcrypto 71d98a03b3 add warning to REST API page 2022-02-08 18:30:59 +01:00
Ștefan Talpalaru e03a653bbe
update AllTests-mainnet.md (#3363) 2022-02-08 15:39:15 +01:00
Eugene Kabanov 40c77e5928
Remote KeyManager API and number of fixes/tests for KeyManager API (#3360)
* Initial commit.

* Fix current test suite.

* Fix keymanager api test.

* Fix wss_sim.

* Add more keystore_management tests.

* Recover deleted isEmptyDir().

* Add `HttpHostUri` distinct type.
Move keymanager calls away from rest_beacon_calls to rest_keymanager_calls.
Add REST serialization of RemoteKeystore and Keystore object.
Add tests for Remote Keystore management API.
Add tests for Keystore management API (Add keystore).
Fix serialzation issues.

* Fix test to use HttpHostUri instead of Uri.

* Add links to specification in comments.

* Remove debugging echoes.
2022-02-07 22:36:09 +02:00
Jacek Sieka c7abc97545
harden and speed up block sync (#3358)
* harden and speed up block sync

The `GetBlockBy*` server implementation currently reads SSZ bytes from
database, deserializes them into a Nim object then serializes them right
back to SSZ - here, we eliminate the deser/ser steps and send the bytes
straight to the network. Unfortunately, the snappy recoding must still
be done because of differences in framing.

Also, the quota system makes one giant request for quota right before
sending all blocks - this means that a 1024 block request will be
"paused" for a long time, then all blocks will be sent at once causing a
spike in database reads which potentially will see the reading client
time out before any block is sent.

Finally, on the reading side we make several copies of blocks as they
travel through various queues - this was not noticeable before but
becomes a problem in two cases: bellatrix blocks are up to 10mb (instead
of .. 30-40kb) and when backfilling, we process a lot more of them a lot
faster.

* fix status comparisons for nodes syncing from genesis (#3327 was a bit
too hard)
* don't hit database at all for post-altair slots in GetBlock v1
requests
2022-02-07 19:20:10 +02:00
tersec bf3ef987e4
deactivate doppelganger protection during genesis (#3362)
* deactivate Doppelganger Protection during genesis

* also don't actually flag supposed-doppelgangers (because they're before broadcastStartEpoch) on GENESIS_SLOT start
2022-02-07 07:12:36 +02:00
Ștefan Talpalaru 70579f2fb1
Jenkins: macOS ARM64 CI job (#3128) 2022-02-04 14:43:40 +01:00
Jacek Sieka 6f10e651ff
rest: fix ssz preference string (#3357) 2022-02-04 15:26:27 +02:00
tersec e0fb5d95a6
remove --subscribe-all{att,sync}nets (#3359) 2022-02-04 12:34:03 +00:00
tersec 02349b4181
update to engine API alpha.6 (#3351) 2022-02-04 12:12:19 +00:00
tersec d358299875
fork choice proposer boosting support (#3349)
* fork choice proposer boosting support

* detect nodeDelta underflow/overflow
2022-02-04 12:59:40 +01:00
Jacek Sieka a50e21e229
fix doppelganger detection logging
* update action tracker on dependent-root-changing reorg (instead of
epoch change)
* don't try to log duties while syncing - we're not tracking actions yet
* fix slot used for doppelganger loss detection
2022-02-04 12:25:32 +01:00
Jacek Sieka 49282e9477
val_mon: register locally produced aggregates (#3352)
These use a separate flow, and were previously only registered from the
network

* don't log successes in totals mode (TMI)
* remove `attestation-sent` event which is unused
2022-02-04 08:33:20 +01:00
tersec 9c18765b3b
remove ncli_db pruneDatabase (#3356) 2022-02-03 20:03:01 +01:00