345 Commits

Author SHA1 Message Date
dapplion
accee2b8be Merge remote-tracking branch 'upstream/dev' into attestation-index 2024-03-05 17:19:49 +08:00
Hsiao-Wei Wang
0b5bb1ae3f
Merge branch 'dev' into pr3563 2024-01-15 19:09:28 +08:00
Hsiao-Wei Wang
b594347780
Merge pull request #3549 from etan-status/lc-finsend
Gossip additional `LightClientFinalityUpdate` on new supermajority
2024-01-15 18:58:24 +08:00
Etan Kissling
c41c128c76
Use Custom types section instead of Helper types for consistency 2024-01-09 14:55:22 +01:00
Etan Kissling
fca5e3b06a
Use proper types when dealing with LC Merkle proofs 2023-12-27 13:59:31 +01:00
Etan Kissling
3e5427e31e
Align formatting 2023-12-27 12:54:36 +01:00
Etan Kissling
316ea98792
Use types for representing LC Merkle branches
For better legibility and alignment with `ethereum/beacon-APIs`, use
named types for the various Merkle branches used in the LC protocol.

- https://github.com/ethereum/beacon-APIs/blob/v2.4.2/types/altair/light_client.yaml#L2-L22
2023-12-27 12:42:29 +01:00
dapplion
e8e00f332a move attestation index outside signed message 2023-12-05 14:16:07 +02:00
Etan Kissling
dd65aa0cb2
Gossip additional LightClientFinalityUpdate on new supermajority
When new finality is reached without supermajority sync committee
support, trigger another event push on beacon-API and libp2p once
the new finality gains supermajority support.

Without this, if the first `LightClientFinalityUpdate` that advances
finality has low participation, light clients monitoring gossip would
likely get stuck until the next time when finality advances (1 epoch).

Thanks to @DragonDev1906 for reporting this issue to Nimbus:

- https://github.com/status-im/nimbus-eth2/issues/5491
2023-11-14 22:28:16 -08:00
Etan Kissling
d9e53cbaf5
Merge branch 'dev' into lc-gindexname 2023-11-06 12:32:53 +01:00
Etan Kissling
89c986ee6a
Rename _INDEX generalized index constants to _GINDEX
To assist with readability, use `_GINDEX` suffix when referring to
generalized index constants.

Does neither affect consensus, beacon-API nor builder API.
2023-11-01 13:30:55 +01:00
Hsiao-Wei Wang
0e4737eba2
Add a general compute_merkle_proof helper to replace container-specific helpers 2023-10-30 14:44:32 +08:00
terence tsao
59680c0470 remove: old warnings 2023-09-05 08:59:14 -07:00
dapplion
680b026d59 Add add_validator_to_registry fn 2023-05-09 19:18:42 +09:00
Danny Ryan
5e1153311b
Merge pull request #3307 from dapplion/reuse-indexes
EIP6914 - Reuse indexes with full sweep
2023-04-19 17:57:12 -06:00
Hsiao-Wei Wang
03a3e4082a
Fix p2p-interface.md ToC 2023-04-19 19:10:46 +08:00
dapplion
622c9b97ba Fix CI 2023-04-04 12:00:09 +09:00
dapplion
3d9c87b27c Move to misc helpers 2023-03-30 09:44:34 +09:00
dapplion
f696b30608 Address PR review 2023-03-30 09:11:36 +09:00
dapplion
314b040fff Reduce line len 2023-03-28 17:45:52 +09:00
dapplion
ee3e1ac63e Apply review comments 2023-03-28 15:34:07 +09:00
dapplion
f9b359be09 Reuse indexes with full sweep 2023-03-28 12:44:21 +09:00
Hsiao-Wei Wang
de57f2ac91
Merge pull request #3284 from etan-status/lc-forkversion
Check correct fork version in LC sync protocol
2023-03-16 09:08:01 +08:00
Etan Kissling
54c7df5bbf
Fix lint 2023-03-08 15:42:56 +01:00
Etan Kissling
43e714e60f
Check correct fork version in LC sync protocol
- Sync committee is determined by signature_slot
- Signature fork version is determined by max(signature_slot, 1) - 1
- Attested block fork version can be anything < signature_slot

Old logic incorrectly derived signature fork version from signature_slot
and did not subtract a slot. Extended tests to check this edge case.
2023-03-08 15:34:56 +01:00
Mikhail Kalinin
13f3654296 Apply suggestions from @djrtwo 2023-03-02 17:29:22 +06:00
Hsiao-Wei Wang
2b2ffb5229
Merge pull request #3190 from etan-status/lc-headerwrapper
Add `LightClientHeader` wrapper
2023-01-13 00:40:44 +08:00
GeemoCandama
d23d0147c8
Update p2p-interface.md
fixed typo
2023-01-07 14:28:12 -06:00
Etan Kissling
b951ce077a
Move helper 2023-01-06 20:01:02 +01:00
Etan Kissling
5230c1ba87
Add is_valid_light_client_header and comments 2023-01-06 19:58:23 +01:00
Etan Kissling
5c64a2047a
Add LightClientHeader wrapper
In Altair, light client sync protocol exchanges `BeaconBlockHeader`
structures for tracking current progress. Wrapping `BeaconBlockHeader`
inside a `LightClientHeader` allows future extensions of this header,
e.g., to also track `ExecutionPayloadHeader`.

Note: This changes the JSON REST format by adding a `beacon` nesting.
For SSZ, the serialization format stays same (but overall root changes).
2023-01-05 13:36:04 +01:00
Hsiao-Wei Wang
0777a52f55
Merge pull request #3149 from etan-status/lc-toheader
Add `block_to_light_client_header` helper
2023-01-05 12:12:36 +08:00
Etan Kissling
ef2a8b319d
Avoid line continuation syntax 2022-12-13 12:30:14 +01:00
Hsiao-Wei Wang
da3f5af919
Test case naming clean up (#3143)
* Add @description decorator

* Unify test case naming style

* more clean ups

* Altair tests cleanup

* Clean up Altair and Bellatrix `process_deposit` tests

* Clean up Bellatrix tests

* Clean up Capella tests

* PR feedback from @ralexstokes

* Add comments on the deposit fork version tests

* Remove `test_incorrect_sig_other_version` since it is duplicate to `test_ineffective_deposit_with_bad_fork_version`

* Add `test_ineffective_deposit_with_current_fork_version`
2022-12-13 15:13:44 +08:00
Etan Kissling
8bf801ecc6
Add block_to_light_client_header helper
Introduce `block_to_light_client_header` helper function to enable
future forks to override it with additional info (e.g., execution),
without having to change the general light client logic.

Likewise, update existing light client data creation flow to use
`block_to_light_client_header` and default-initialize empty fields.

Furthermore, generalize `create_update` helper to streamline test code
using `block_to_light_client_header`.

Note: In Altair spec, LC header is the same as `BeaconBlockHeader`.
however; future forks will extend it with more information.
2022-12-06 17:44:41 +01:00
Etan Kissling
0fb2447a95
Merge branch 'dev' into lc-blockfuncs 2022-11-19 12:20:18 +01:00
Michael Sproul
897b97990f
Further clarify light client slot checks 2022-11-11 22:09:33 +11:00
Michael Sproul
dae1011194
Fix typos
Co-authored-by: Alex Stokes <r.alex.stokes@gmail.com>
2022-11-09 09:41:21 +11:00
Michael Sproul
91de8a09f3
Fix slot checks in light client p2p spec 2022-11-08 17:06:07 +11:00
Etan Kissling
08ff71688f
Merge branch 'dev' into lc-blockfuncs 2022-11-07 15:03:20 +01:00
Hsiao-Wei Wang
87dcb83827
Merge pull request #3063 from etan-status/lc-gossipdigests
Document how to derive fork context for LC gossip
2022-11-02 13:12:23 +08:00
Etan Kissling
ff0e525ecc
Pass blocks to LC data creation functions
Future light client protocol extensions may include data from the block
in addition to data from the state, e.g., `ExecutionPayloadHeader`.
To prepare for this, also pass the block to the corresponding functions.
In practice, blocks access is easier than historic state access, meaning
there are no practical limitations due to this change.
2022-10-28 22:14:25 +02:00
Alex Stokes
be3c774069
Merge pull request #3065 from etan-status/lc-branchrootdocs
Clarify where LC proofs are rooted
2022-10-28 08:51:26 -06:00
Etan Kissling
5b6eb8007a
Clarify where LC proofs are rooted
Add more detailed LC object documentation to explain that the various
merkle proofs are relative to the beacon block's state root.
Likewise, clarify that sync committees relate to the finalized header
(not to the optimistic header, which can be a period ahead).
2022-10-27 21:44:38 +02:00
Etan Kissling
af54c97a6c
Consistently use compute_sync_committee_period_at_slot
A few LC functions were not yet updated to use a more concise function
for computing sync committee period for a slot. Updating to that func.
2022-10-27 21:36:55 +02:00
Etan Kissling
c399e11aa7
Document how to derive fork context for LC gossip
For LC gossip, the documentation did not specify what slot number to use
for deriving the gossip objects. This missing documentation is now added
to document using `attested_header.slot`.
2022-10-27 21:23:09 +02:00
Lion - dapplion
fda2a69ff7
Typo in sync committee duties description
I assume it refers to producing a signature for the last slot of phase0 fork
2022-10-02 12:19:55 +02:00
Ben Guidarelli
d70dcd9926
Fix link to beacon-chain doc 2022-09-15 10:21:06 -04:00
Etan Kissling
52a741f7c6
Improve grammar
Co-authored-by: Hsiao-Wei Wang <hsiaowei.eth@gmail.com>
2022-07-25 15:46:29 +02:00
Etan Kissling
56363cd94a
Define libp2p protocol for light client sync
While the current Altair specs define structures to aid light client
development, one missing key aspect is the network protocol definition.

Certain implementations have started defining their own REST based APIs,
e.g., Lodestar at https://github.com/ChainSafe/lodestar/blob/master/packages/api/src/routes/lightclient.ts
While such APIs are useful, REST does not seem to be the ideomatic
choice as the sole API available at such a low level for Ethereum.

This patch introduces a libp2p based protocol to allow light clients to
sync to the latest `BeaconBlockHeader` in a trustless and decentralized
manner, building on top of prior work from:
- @hwwhww at https://github.com/ethereum/consensus-specs/pull/2267
- @jinfwhuang at https://github.com/ethereum/consensus-specs/pull/2786
- Lodestar's REST API (also has an endpoint to fetch merkle proofs!)
2022-07-22 17:56:41 +02:00